Question

Our company subversion repo is a bit tricky: We've got a basic "default" layout with trunk, tags and branches. However, inside the branches, we have a "work" directory which contains more branches. Something like this:

  • branches/release_1_0_x
  • branches/release_1_1_x
  • branches/work/dave/topic_one
  • branches/work/tom/topic_two
  • branches/work/something_else

Now how can I get git-svn to recognize all those (and a few more) as separate branches? It appears git svn init only accepts one branch location, how ever I'm invoking it.

Edit: this is how I initialized the git repo:

git svn clone  -s --prefix=svn/ http://svn.company.com/product/
Was it helpful?

Solution

According to the answer to another question, your best bet is to use Git 1.6.x and take advantage of "deep cloning".

If you can't upgrade to 1.6.x, then you can specify multiple branches when you clone.

git svn clone -s --prefix=svn/ -b branches -b branches/work/dave -b branches/work/tom ...

You'll just have to make sure you add info for new users to your .git/config before "git svn fetch"ing when a new user branch has been added.

OTHER TIPS

You can add multiple branches and tags entries in your git-svn config, even retroactively. So if normally SVN branches live in branches/* in your SVN repo (ie. a standard layout), but you also have branches/summer-students/*, you can set it up in .git/config like below:

[svn-remote "svn"]
    url = svn+ssh://svn.example.com
    fetch = trunk:refs/remotes/trunk
    branches = branches/*:refs/remotes/*
    tags = tags/*:refs/remotes/tags/*

    branches = branches/summer-students/*:refs/remotes/svn-summer-students/*

On the left of the : is the path in the SVN Repo, and on the right is the path it will appear as in your git remote branch list. You can use refs/remotes/* repeatedly to have everything appear as a top-level remote branch, but watch out for name collisions - they will break things (hence svn-summer-students instead of summer-students, which already exists).

After you edit the config, you need to delete .git/svn/.metadata and run git svn fetch to refresh the branch list and regenerate it. git branch -r should then show the extra branches. If you get errors, look out for naming collisions.

The git svn docs have some more examples of specifying paths via wildcards or expressions if you have a funky SVN layout.

For those looking to do this retroactively, the git-svn manpage for 1.7.x says:

It is also possible to fetch a subset of branches or tags by using a comma-separated list of names within braces. For example:

[svn-remote "huge-project"]
     url = http://server.org/svn
     fetch = trunk/src:refs/remotes/trunk
     branches = branches/{red,green}/src:refs/remotes/branches/*
     tags = tags/{1.0,2.0}/src:refs/remotes/tags/*
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top