Thorsten Krüger
Thorsten Krüger

Reputation: 49

Accessing a mixed branches folder layout using git-svn

I am trying to use git svn to connect to our company repository. We have a slightly non-standard branches directory. How to access this using git svn has been discussed before, however, we seem to have a slight twist in our branch names that seems to keep me from getting them all.

Let's consider an example svn repo:

trunk/
tags/
branches/
    rootbranch/
    tku/subbranch

We have branches at the root level of the branches directory. But we have branches in nested folders, as well. The same goes for the tags dir, but I think that is just a second example of the same problem.

If I use git svn clone file:///tmp/gitsvn/svnrepo git-clone -s, I get only the root branches, as expected:

/tmp/gitsvn/git-clone$ git branch -r
  rootbranch
  tku
  trunk

But if I clone using _git svn clone file:///tmp/gitsvn/svnrepo git-clone2 -b branches//_, I get only the sub-branches:

/tmp/gitsvn/git-clone2$ git branch -r
  tku/subbranch

Is there a way to have both?

Upvotes: 1

Views: 2074

Answers (2)

caedwa
caedwa

Reputation: 31

Additional branches can be accessed by adding multiple branches lines to the git-svn config.

In the .git/config file, there will be a section similar to the following:

[svn-remote "svn"]
  url = http://server/svn
  fetch = trunk:refs/remotes/trunk
  branches = branches/*:refs/remotes/branches/*
  tags = tags/*:refs/remotes/tags/*

Simply add another entry for the extra directory of branches. For example:

branches = branches/tku/*:refs/remotes/branches/tku/*

Then run git svn fetch to retrieve the branches from the svn repository.

I believe it's also possible to create this setup when constructing the git repository, using multiple -b options to the clone command.

git svn clone http://svn.foo.org/project -T trunk -b branches -b branches/tku -t tags

Upvotes: 3

Thorsten Krüger
Thorsten Krüger

Reputation: 49

For anyone else who stumbles over this: it seems that having both is not possible. Subversion allows a mixed setup of branches, but it is discouraged, and so it seems okay that git does not support this. My solution was to bring all branches to the same level, then forget about the issue and move on. Having only one level of branches seems better anyway.

Upvotes: -1

Related Questions