理想的解决方案是在SubGit配置中指定trunk:refs/heads/master映射,因此SubGit会将trunk与master同步,忽略任何其他分支.
不幸的是,SubGit目前至少需要一个分支映射(版本1.0.x和2.0.x).也就是说,必须指定如下内容:
trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
shelves = shelves/*:refs/shelves/*
tags = tags/*:refs/tags/*
Run Code Online (Sandbox Code Playgroud)
由于您不打算同步所有Git分支,因此请考虑使用一些特殊的命名空间来解决此问题:
trunk = trunk:refs/heads/master
branches = branches/*:refs/gitsvn/heads/*
...
Run Code Online (Sandbox Code Playgroud)
因此,如果将master分支推送到中央Git存储库,它将被转换为trunk.但是,如果一个推动分支foo,SubGit会忽略该分支,因为refs/heads/foo不同步范围.
麻烦来自合并提交:如果提交A是将分支foo合并到master中的结果,则SubGit 在Subversion端为commit A的相应父代创建branches/foo.如果您不希望将SubGit生成的分支包含到*分支中/**命名空间,考虑在Subversion端使用一些特殊的分支:
trunk = trunk:refs/heads/master
branches = gitsvn/branches/*:refs/gitsvn/heads/*
shelves = shelves/*:refs/shelves/*
tags = gitsvn/tags/*:refs/gitsvn/tags/*
Run Code Online (Sandbox Code Playgroud)
在这种情况下,应将提交A的同一父节点发送到gitsvn/branches/foo分支.
这是目前最好的解决方案.我们还有2.1版的功能请求,可以为您提供理想的解决方案,但在实施之前需要一些时间.
SubGit 3.0更新:
从版本3.0.0(目前的早期访问阶段,在http://subgit.com/eap下载)SubGit支持单分支布局,因此配置文件可能如下所示:
没有行李箱,没有分支,没有标签,没有货架:
[svn]
url = http://host.com/repos/project
Run Code Online (Sandbox Code Playgroud)
在这种情况下,项目目录直接映射到Git存储库中的master分支; SubGit忽略任何其他分支,并且永远不会创建货架,这意味着匿名Git分支不会同步到SVN.
单箱,无货架:
[svn]
url = http://host.com/repos/project
trunk = trunk:refs/heads/master
Run Code Online (Sandbox Code Playgroud)
在这种情况下,project/trunk目录映射到Git存储库中的master分支; SubGit忽略任何其他分支,从不创建货架.
带架子的单人行李箱:
[svn]
url = http://host.com/repos/project
trunk = trunk:refs/heads/master
shelves = shelves/*:refs/shelves/*
Run Code Online (Sandbox Code Playgroud)
在这种情况下,project/trunk目录映射到Git存储库中的master分支; SubGit忽略任何其他分支,但它默认将版本1.0.x和2.0.x转换为匿名分支到货架.
希望有所帮助.