Update: I've since written a script that automates this, see the follow up Fetching svn branches with git-svn .
The git-svn man page is less than helpful about how to track 2 subversion branches (actually, trunk and another branch). Typically trunk is the development branch and you have another branch for release that you backport fixes to. You can fetch all branches easily, but many times you don't want to and just want a particular branch. After many tries I've found something that works.
After you cloned a git-svn repository, you should have something like this in your .git/config:
[svn-remote "svn"]
url = svn://svn/mgmt/trunk
fetch = :refs/remotes/git-svn
Append the branch that you want:
[svn-remote "foo"]
url = svn://svn/mgmt/branches/foo_branch
fetch = :refs/remotes/git-foo
Then do:
git svn fetch -R foo -r 31144 # or whatever revision you want to start with
git branch -av # should see a new remote branch
git branch --track foo_branch git-foo
After you do this, you should see your .git/config now has a new entry:
[branch "foo_branch"]
remote = .
merge = refs/remotes/git-foo
git svn rebase your new branch:
git checkout foo_branch
git svn rebase
Now you can cherry-pick revisions from foo_branch, and dcommit as usual.
Append the branch that you want:
[svn-remote "foo"] url = svn://svn/mgmt/branches/foo_branch fetch = :refs/remotes/git-foo
I tried "RELEASE_X_Y" and it doesn't like it. Apparently underscore causes git svn fetch to malfunction; checking it to "stable" works. Thanks for the tips - I was looking for how to track trunk and release_X_Y of a small module in a big svn repository (and don't want to clone the whole lot) and your advice works! As you write, man git-svn isn't really helpful...
You are welcome!
Hi, thanks for this post. However, when I run
git svn fetch -R foo -r 31144 # or whatever revision you want to start with git branch -av # should see a new remote branch
git-branch -av doesn't list a new remote branch. I should note that the second svn repository I am trying to connect to is empty. I have not idea what to do about this. I've noticed that an empty folder is created at .git/svn/refs/remotes/XXX/
Hi, thanks for this post. However, when I run
git svn fetch -R foo -r 31144 # or whatever revision you want to start with git branch -av # should see a new remote branch
git-branch -av doesn't list a new remote branch. I should note that the second svn repository I am trying to connect to is empty. I have not idea what to do about this. I've noticed that an empty folder is created at .git/svn/refs/remotes/XXX/
Hi, thanks for this post. However, when I run
git svn fetch -R foo -r 31144 # or whatever revision you want to start with git branch -av # should see a new remote branch
git-branch -av doesn't list a new remote branch. I should note that the second svn repository I am trying to connect to is empty. I have not idea what to do about this. I've noticed that an empty folder is created at .git/svn/refs/remotes/XXX/
yes it doesn't seem to work for empty svn branches, so you have to use svn to create an initial commit first