Manual git-svn clone

I finally decided to do something about the five independent git trees I had on my hard drive at work. The problem is they are all really branches of the same subversion repository, and moving patches back and forth between them meant I had added them all as git remotes to each other. The meta problem is that we didn’t always branch off of the same trunk directory, from back when we were drinking the “just snapshots of directories” subversion kool-aid, so git svn clone doesn’t do the right thing for our branches.

The ideal setup is one where I have a git branch for each subversion branch all in one tree, and git svn dcommit will go to the right place. As it turns out, this isn’t too hard to achieve, but requires a lot of waiting around when building the repository. You just manually add different svn-remote sections to your .git/config, then run git svn fetch for each one:

$ cat .git/config
[...]
[svn-remote "svn"]
url = svn+ssh://server/svn/trunk/
fetch = :refs/remotes/git-svn
[svn-remote "svn-bar"]
url = svn+ssh://server/svn/branches/foo/bar
fetch = :refs/remotes/git-svn-bar
[...]
$ git svn fetch
$ git svn fetch svn-bar
$ git checkout -b bar svn-bar

Now ‘bar’ is a branch tracking the directory in branches/foo/bar, master is your normal trunk line of development, and git svn dcommit just works. Having 8 years of history in a 400 meg local tree is pretty nice.