git-svn 如何更换了URL

随着Project的开发,可能SVN URL改变了(很多原因,比如域名改变,比如版本升级,再比如一不小心使用了http,想换到https等),那么如果使用SVN,很简单,直接relocate就可以了,但是以前同步使用的Git Project如何跟着变化了,上网查了一下,发现比较有效的来自下面。

https://git.wiki.kernel.org/articles/g/i/t/GitSvnSwitch_8828.html

【引用开始】

General Case

What immediately sprang to mind, and what was suggested e.g. on the mailing list, was to simply edit your .git/config, and change the url= in the section [svn-remote “svn”]. That doesn’t work, however. Instead, I found several suggestions to use variations of this theme:

l  Edit the svn-remote url URL in .git/config to point to the new domain name

l  Run git svn fetch – This needs to fetch at least one new revision from svn!

l  Change svn-remote url back to the original url

l  Run git svn rebase -l to do a local rebase (with the changes that came in with the last fetch operation)

l  Change svn-remote url back to the new url

l  Run git svn rebase should now work again!

This will only work, if the git svn fetch step actually fetches anything! (Took me a while to discover that… I had to put in a dummy revision to our svn repository to make it happen!)

【引用结束】

注:红色部分请注意下。

本人已经验证这个方法是可以成功切换SVN URL的。

发表评论