SubGit: How to exclude branches?

我的梦境 提交于 2019-12-21 13:22:17

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/16588228/subgit-how-to-exclude-branches

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!