使用 kan 写的我想出了这个解决方案:
git clone cvs.git
cd cvs
git remote add svn ../../svn.git
git fetch svn
用于git log --all
查找未连接的历史记录:
...
|
* ab42f52 2011-09-14 06:03:07 +0000 | [svnuser]
|
* 1985b93 2011-09-14 06:00:00 +0000 | Migration from CVS [svnuser]
* 12e0ed4 2011-09-14 05:58:10 +0000 | *** empty log message *** (HEAD, origin/master, origin/HEAD, master) [cvsuser]
|
* 5060a7f 2011-04-18 14:07:03 +0000 | *** empty log message *** [cvsuser]
|
...
找到完整的 SHA1:
git show 1985b93
git show 12e0ed4
创建嫁接:
echo 1985b9305ebc819e760f7ecf8e2abe7963eac055 12e0ed4c3dd75cec396a2d228825702eab73ba19 > .git/info/grafts
现在历史是相互关联的,但还不是永久的:
|
* ab42f52 2011-09-14 06:03:07 +0000 | [svnuser]
|
* 1985b93 2011-09-14 06:00:00 +0000 | Migration from CVS (grafted) [svnuser]
|
* 12e0ed4 2011-09-14 05:58:10 +0000 | *** empty log message *** (HEAD, origin/master, origin/HEAD, master) [cvsuser]
|
* 5060a7f 2011-04-18 14:07:03 +0000 | *** empty log message *** [cvsuser]
|
使其永久化,如http://bugsquash.blogspot.co.uk/2010/03/stitching-git-histories.html所示:
git branch svnmaster svn/master
git filter-branch -- 12e0ed4c3dd75cec396a2d228825702eab73ba19..svnmaster
这会创建新的提交,但也会留下原始的 svn 提交。 git log --all
将显示它:
* 849278b 2013-04-15 16:31:44 +0000 | Java 6 in Eclipse. Deployed. (svnmaster) [svnuser]
|
...
|
* c33f7cc 2011-09-14 06:03:07 +0000 | [svnuser]
|
* 7acb3ed 2011-09-14 06:00:00 +0000 | Migration from CVS [svnuser]
|
| * b3d5413 2013-04-15 16:31:44 +0000 | Java 6 in Eclipse. Deployed. (svn/master, refs/original/refs/heads/svnmaster) [svnuser]
| |
...
| |
| * ab42f52 2011-09-14 06:03:07 +0000 | [svnuser]
| |
| * 1985b93 2011-09-14 06:00:00 +0000 | Migration from CVS (grafted) [svnuser]
|/
|
* 12e0ed4 2011-09-14 05:58:10 +0000 | *** empty log message *** (HEAD, origin/master, origin/HEAD, master) [cvsuser]
|
* 5060a7f 2011-04-18 14:07:03 +0000 | *** empty log message *** [cvsuser]
|
移除嫁接,重复的历史将消失:
rm -r .git/info/grafts .git/refs/original
清理:
git reset --hard svnmaster
git branch -D svnmaster
并推动:
git push
全部做完!