git and svn: add another branch

July 10, 2008 – 16:12

If you use git as your software project workhorse and yet have to track remote svn repo, then you might be interested.

Today I had to add tracking of another svn branch.

Git branches are essentially no-op. Svn are not that good, but nevertheless…

But git clone of yet-another-svn-branch (in the existing repo) appeared to be an issue.

Thanks to dmo.ca, this was finally done.

In short, you have to add another svn-remote to your .git/config:

[svn-remote "additional-svn"]
    url = svn+ssh://your-server/home/svn/project-name/trunk
    fetch = :refs/remotes/git-svn

and then fetch the revision that is on the branch of interest (that’s important):

git-svn fetch additional-svn  -r MMMM

After it completes, you may check your branches with

git branch -r