Alex Rivera | Logout

git-svn - Checkout a remote branch that already exists in svn when my master is already a branch. Explain this .git/config

Asked 2011-02-15T13:00:01.750
10

This is a bit of an oddball question given how the team I've joined is using SVN. Basically, the svn repository follows a standard layout, but trunk really hasn't been touched in 1.5 years or so and work tends to happen in branches and branches of branches only. As such, I've used git-svn to clone from the branch that represents the active branch for our next release and that is what master tracks in my local git repository. Let's call this branch in svn 'release' from here on out. Using git-svn for this purpose is just hunky dory.

Now, someone has created a feature branch off of 'release', that I'm going to call 'feature', that I'd like to pull down to a local branch of mine, and commit to as well. Sure, I can get away with just cloning that branch off into another directory/git repository locally, but what I'd really like to do is have 'feature' mirrored in a local branch within my local git repository as well to make merging between the two as straightfoward as possible. I've seen other stackoverflow.com posts show how this works assuming you've used git svn init with --stdlayout, but I didn't do that in my case for the reasons stated above.

Here is my .git/config

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[svn-remote "svn"]
    url = https://our.svn.server/svn/root/branches/release
    fetch = :refs/remotes/git-svn

I'm assuming what I need in my [svn-remote] section is a branches = $something but I don't know what that $something is in this case nor what incantation of git checkout and other commands I need after I make that change to .git/config.

Any suggestions?


Edit - The following works:

So I started from scratch and did the following clone command:

git svn clone https://

Edit
Report

1 Answer

2

Have you tried just adding branches=.. to your svn-remote section? (presuming url points directly at your release branch). You'll get an extra release head tracking the release branch, but then you'll get all the other branches tracked too so that you can check them out. As a bonus git svn branch will (probably) work for creating new branches too!

As a side note, you could have also just used --stdlayout to clone your svn repo, and then set master up to track release instead of trunk. That's not hard to do either.

answered 2011-02-20T22:27:33.030

Your Answer