I figured out a way to infer multiple branches from an arbitrary svn repository structure.
The -b for git svn init will work only if all branches are grouped together in a subdirectory in the repository, for example, in a standard layout. If all branches, including the trunk, are located nearby in the same folder, this will not work. You can pull the selected branches from the svn repository, essentially creating a few "trunks" in your git repository.
Suppose a flat question structure is associated with three branch branches, featureX and featureY.
Create an instance of your git repository.
mkdir myproject cd myproject git svn init url:to/svn/repo -T trunk
This will create a git repository with svn metadata in the .git/config file.
Open the configuration file and check svn metadata
vim .git/config
Your configuration file will look something like this.
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true autocrlf = false [svn-remote "svn"] url = url:to/svn/repo fetch = trunk:refs/remotes/trunk
The svn-remote header defines a link called "svn" that points to your svn repository. The fetch parameter tells git-svn where to get the new revisions from the svn repository. Now we need to tell git-svn about another branch of interest to us.
Duplicate the svn-remote section
Copy the entire svn-remote section of the configuration file and paste it below the existing configuration text.
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true autocrlf = false [svn-remote "svn"] url = url:to/svn/repo fetch = trunk:refs/remotes/trunk [svn-remote "svn"] url = url:to/svn/repo fetch = trunk:refs/remotes/trunk
Change the new svn-remote partition
Change the name of the svn-remote section header and the name of the branch it points to.
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true autocrlf = false [svn-remote "svn"] url = url:to/svn/repo fetch = trunk:refs/remotes/trunk [svn-remote "svn-featureX"] url = url:to/svn/repo fetch = featureX:refs/remotes/featureX
Now git-svn will track both branches of svn. You can use the names "svn" and "svn-featureX" with any git [svn-remote] that accepts the [svn-remote] parameter. You can use the names "trunk" and "featureX" with any git command that takes the name of the remote branch as a parameter.
This solution will not scale well and hack a little work with the wrong svn repository. As long as you only need to track multiple svn branches, this will work just fine. If the number of svn branches you need to work with becomes too large, take a serious look at restructuring your svn repository into a standard layout.
source share