git-svn – switch to a different a svn url

I’m using git and git-svn for all my projects now. It’s wonderful to use git even if the main repository is still in Subversion. Recently though, I had a problem where the Redmine svn repository url changed. Normally you are just recommend to clone the new subversion url with a fresh git-svn repository. Unfortunately, my Redmine git repository is publicly published and several people are actively developing with it. If I re-cloned, all of the commit SHAs would change and I’d have a lot of angry people knocking on my (virtual) door.

Not being content with just having multiple git repositories lying around, I searched the interwebs and stumbled upon the GitSvnSwitch page on the git wiki. It described a funky process where you can change the url for a svn repository without rewriting all the commits. The process went like this:

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

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

  3. Change svn-remote url back to the original url

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

  5. Change svn-remote url back to the new url

  6. Run git svn rebase should now work again!

I’m still not entirely sure what it did but somehow in between steps 4 and 6 the git-svn-id changed to the new url without git-svn complaining. The results of this switch over can be seen in commit ae0ed7f.

Now I have one git-svn repository that can pull commits from Redmine’s svn, push and pull to GitHub, and I can use it to commit back to Redmine. The greatest benefit though, is I can now start to check out the other Redmine forks on GitHub for some new code. If you are the owner of one of those forks and have some killer code, send me a pull request and I’ll see about pushing it back into the Redmine core.