我已经使用 gitsvn 签出了一个 svn 存储库。现在我需要检查其中一个树枝,然后追踪它。哪种方法最好?
创建一个包含 Subversion 主干、标记和分支的 git 克隆
git svn clone http://svn.example.com/project -T trunk -b branches -t tags
The --stdlayout option is a nice shortcut if your Subversion repository uses the typical structure:
--stdlayout
git svn clone http://svn.example.com/project --stdlayout
让你的 git 仓库忽略 subversion repo 所做的一切:
git svn show-ignore >> .git/info/exclude
You should now be able to see all the Subversion branches on the git side:
git branch -r
假设 Subversion 中的分支名称为 waldo
waldo
git checkout -b waldo-svn remotes/waldo
The -svn suffix is to avoid warnings of the form
warning: refname 'waldo' is ambiguous.
要更新 git 分支 waldo-svn,请运行
waldo-svn
git checkout waldo-svn git svn rebase
要将 Subversion 分支添加到只包含主干的克隆,请修改 git 存储库的 .git/config以包含
.git/config
[svn-remote "svn-mybranch"] url = http://svn.example.com/project/branches/mybranch fetch = :refs/remotes/mybranch
你需要养成跑步的习惯
git svn fetch --fetch-all
to update all of what git svn thinks are separate remotes. At this point, you can create and track branches as above. For example, to create a git branch that corresponds to mybranch, run
git svn
git checkout -b mybranch-svn remotes/mybranch
对于您打算从其中分支 git svn dcommit,保持其历史线性!
git svn dcommit
你也可能对阅读 回答相关问题感兴趣。