对于 Git,请参阅http://github.com/guides/import-from-subversion上的说明
上次我手动执行此操作时,我使用了以下命令。(这是针对不使用标签或分支的项目。如果您有标签或分支,使用svn2git可能会产生比 git-svn 更好的结果。)
cat "mysvnusername = Me Myself <me.myself@somewhere.com>" >> authors.txt
svnserve --daemon --foreground --root <SVN-REPO-PARENT-DIR>
git svn clone --stdlayout --authors-file=authors.txt --no-metadata svn://localhost/<SVN-REPO-NAME>
# push to a public repo and clone from there, to get push/pull working easily
cd <SVN-REPO-NAME>
git remote add origin git@github.com:mygithubusername/<GIT-REPO-NAME>.git
git push origin master
cd ..
rm -rf <SVN-REPO-NAME>
git clone git@github.com:mygithubusername/<GIT-REPO-NAME>.git
但是由于您有一个非标准的 SVN 存储库布局,您需要为git svn clone指定 --trunk、--tags 和 --branches 参数而不是 --stdlayout 。
为了表示存储库的整个继承历史,您可以尝试重新排序存储库,以便您拥有标准的平面存储库布局,而不是非标准层次结构:
/branches/original-0.1
/branches/original-0.2
/branches/variantA-trunk
/branches/variantA-who-branch_for_xxx
/branches/variantA-she-branch_for_yyy
/branches/variantB-trunk
/branches/variantB-who-branch_for_zzz
...
这应该使导入工具更容易理解存储库。然后,当它们被导入后,您可以在新存储库中更好地重新组织它们。
另外,我听说 Git 1.6.x 支持深度克隆,因此您可以提供git svn clone
参数,例如--branches=branches/*/*
可以深入查看分支层次结构的参数。有关使用它的示例,请参见这篇文章。