我已经设置 subgit 将一个汇编 svn 存储库镜像到 git。我只想使用 svn->git 方式。无论如何,我无权提交 svn repo,因此 subgit 在尝试同步回 svn (git->svn) 时会出现错误消息。有没有办法做到这一点?
1 回答
如果不将它们转换为 SVN,同时使它们与 SVN 分支保持同步,就不可能支持推送一些 Git 分支。所以解决方案是使用一组 Git 分支,同时保持另一组分支与 SVN 同步。这些同步的分支应该手动定期合并到第一组的分支中。使用 SubGit 有几种方法可以做到这一点。
方法 1.使用单独的命名空间。例如,您可以refs/heads/svn/*
在refs/tags/svn/*
使用refs/heads/*
. 为此,请使用 SubGit 配置文件中的以下选项:
trunk = trunk:refs/heads/svn/master
branches = branches/*:refs/heads/svn/*
tags = tags/*:refs/tags/svn/*
shelves = shelves/*:refs/shelves/svn/*
因此,当您克隆这样的存储库时,SVNtrunk
被转换为refs/remotes/origin/svn/master
,您应该定期手动合并该分支,git merge
以使您的本地refs/heads/master
或多或少与 SVN 保持同步。
方法 2.由于 SubGit 3.0(或3.0.0-EAP版本,直到它发布),您可以将与 SVN 同步的所有分支限制为一个或多个分支(删除其他分支/标签/货架选项):
trunk = trunk:refs/heads/master
branches = branches/branch1:refs/heads/branch1
branches = branches/branch2:refs/heads/branch2
之后refs/heads/branch1
, refs/heads/branch2
, 和refs/heads/master
将与 SVN 同步,refs/heads/branch3
不会。
方法 3.由于 SubGit 3.0(或3.0.0-EAP版本,直到它发布),您可以从同步中排除一个或多个分支:
trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*
shelves = shelves/*:refs/shelves/*
excludeBranches = branches/nosync1
excludeBranches = branches/nosync2
此配置同步refs/heads/*
除refs/heads/nosync1
and之外的所有refs/heads/nosync2
内容,因为如果它们被同步,它们将被转换为branches/nosync1
andbranches/nosync2
被忽略。
实际上你并不局限于这些方法,但你可以根据你的需要混合它们。