GitSvnSwitch
From Git SCM Wiki
When an SVN repository moves, the equivalent of svn switch for git-svn is required.
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 ofthis theme:
- Edit the svn-remote url URL in .git/config to point to the new domain name
- Run
git svn fetch- This needs to fetch at least one new revision from svn! - Change svn-remote url back to the original url
- Run
git svn rebase -lto do a local rebase (with the changes that came in with the last fetch operation) - Change svn-remote url back to the new url
- Run
git svn rebaseshould 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!)
Using git-filter-branch
One can also use git filter-branch directly to rewrite the copied svn-history so that the git-svn-id: points to the right place. This technique has been documented at
this entry on winterstream's blog.
The heart of the technique uses sed to rewrite the git-svn-id: entries, but it also includes some magic with git-gc and awk to do more complete history rewriting.
Using --rewrite-root
In my case, I had a local file:// mirror, that I wanted to use during the initial git svn fetch only. After that I wanted to follow the network on a ssh:// mirror, a 1.2 G 7000 rev SVN repo on the other side of the world. So during the initial git svn fetch I wanted the history to reflect the ssh:// URL for the repos. This worked for me:
$ git svn init -T trunk -t tags -b branches --rewrite-root svn+ssh://server/repo file:///some/path $ git svn fetch # Wait a while
Edit .git/config, changing
rewriteRoot = svn+ssh://server/repo
url = file:///some/path
to
rewriteRoot = svn+ssh://server/repo
url = svn+ssh://server/repo
$ git svn rebase # Now works fine!
But that will only work that once! You can use the "General Case" above several times, though.
Note: I was not able to find much documentation for the --rewrite-root option, except what little is found in man git-svn. However, in man git-svn under svn-remote.<name>.rewriteRoot it says:
these settings should never be changed once they are set
Clearly, here I change the rewriteRoot option in contradition with man git-svn. So use at your own risk! :)
