This page is not available in 繁體中文, as a result the English (en_US) version is shown instead.
Tracking 2 branches in git-svn

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.

by khc on Wed Mar 11 00:13:39 2009 Permlink
Tags: computer work
RE: Tracking 2 branches in git-svn

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...

by anonymous on Tue Aug 19 20:48:40 2008
RE: Tracking 2 branches in git-svn

You are welcome!

by khc on Fri Aug 22 21:59:07 2008