Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SubGit: How to exclude branches?

I'm testing SubGit as a way of migrating from SVN to Git.

What I would like to do is be able to create remote branches in the git repository that all users can use that does not sync back to SVN.

I only want SubGit to track the master branch and sync it back to SVN so that we have the freedom to use and share other Git branches.

Is there a simple way to do this?

Thank you

like image 399
David J Avatar asked May 16 '13 13:05

David J


1 Answers

The ideal solution would be specifying trunk:refs/heads/master mapping in SubGit configuration, so SubGit would synchronize trunk with master ignoring any other branches.

Unfortunately, SubGit needs at least one branches mapping at the moment (versions 1.0.x and 2.0.x). That is, one has to specify something like this:

trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
shelves = shelves/*:refs/shelves/*
tags = tags/*:refs/tags/*

Since you're not going to synchronize all the Git branches, consider using some special namespace to workaround the issue:

trunk = trunk:refs/heads/master
branches = branches/*:refs/gitsvn/heads/*
...

So, if one pushes master branch to central Git repository, it gets translated to trunk. However, if one pushes branch foo, SubGit ignores that branch since refs/heads/foo is out of sync scope.

The troubles come from merge commits: if commit A is the result of merging branch foo into master, then SubGit creates branches/foo on Subversion side for corresponding parent of commit A. If you'd prefer to not include SubGit generated branches into *branches/** namespace, consider using some special branches on Subversion side as well:

trunk = trunk:refs/heads/master
branches = gitsvn/branches/*:refs/gitsvn/heads/*
shelves = shelves/*:refs/shelves/*
tags = gitsvn/tags/*:refs/gitsvn/tags/*

In this case the same parent of commit A should be sent to gitsvn/branches/foo branch.

This is the best solution available at the moment. We also have a feature request for version 2.1 that would enable an ideal solution for you, but it's going to take some time before we implement it.

Update on SubGit 3.0:

Since version 3.0.0 (early access stage at the moment, download at http://subgit.com/eap) SubGit supports single branch layout, so configuration file may look as follows:

  1. No trunk, no branches, no tags and no shelves:

    [svn]
        url = http://host.com/repos/project
    

    In this case, project directory is mapped directly to master branch in Git repository; SubGit ignores any other branches and never creates shelves which mean anonymous Git branches don't get synced to SVN.

  2. Single trunk, no shelves:

    [svn]
        url = http://host.com/repos/project
        trunk = trunk:refs/heads/master
    

    In this case, project/trunk directory is mapped to master branch in Git repository; SubGit ignores any other branches and never creates shelves.

  3. Single trunk with shelves:

    [svn]
        url = http://host.com/repos/project
        trunk = trunk:refs/heads/master
        shelves = shelves/*:refs/shelves/*
    

    In this case, project/trunk directory is mapped to master branch in Git repository; SubGit ignore any other branches but it translates anonymous branches to shelves as by default for versions 1.0.x and 2.0.x.

Hope that helps.

like image 94
vadishev Avatar answered Sep 27 '22 23:09

vadishev