从svn转到git时,是否可以保留所有历史记录? 我发现 svn copy 之前的历史记录丢失了。
我有以下svn存储库:
如果我git svn clone project3,则project1和project2中没有A和B的历史记录。
以下是问题的演示:
> svn co https://localhost/svn/test
> cd test
> mkdir -p project1/trunk project1/branches project1/tags
> mkdir -p project2/trunk/dir project2/branches project2/tags
> mkdir -p project3/trunk project3/branches project3/tags
> touch project1/trunk/A project2/trunk/dir/B
> svn add project1 project2 project3
> svn ci -m 'initial commit'
> svn copy project1/trunk/A project3/trunk/
> svn copy project2/trunk/dir project3/trunk/
> svn ci -m 'project restructure'
每次运行 svn log 都会显示两个版本:
> svn log project3/trunk/A
------------------------------------------------------------------------
r2 | tanderson | 2015-04-16 19:37:33 +1000 (Thu, 16 Apr 2015) | 1 line
project restructure
------------------------------------------------------------------------
r1 | tanderson | 2015-04-16 19:37:32 +1000 (Thu, 16 Apr 2015) | 1 line
initial commit
------------------------------------------------------------------------
> svn log project3/trunk/dir/B
------------------------------------------------------------------------
r2 | tanderson | 2015-04-16 19:37:33 +1000 (Thu, 16 Apr 2015) | 1 line
project restructure
------------------------------------------------------------------------
r1 | tanderson | 2015-04-16 19:37:32 +1000 (Thu, 16 Apr 2015) | 1 line
initial commit
------------------------------------------------------------------------
现在克隆:
> git svn clone --stdlayout --follow-parent https://localhost/svn/test/project3 gittest
Using higher level of URL: https://localhost/svn/test/project3 => https://localhost/svn/test
r1 = 1bc0768d6d823b49305978d227df6834d2787fdc (refs/remotes/origin/trunk)
A A
A dir/B
r2 = c71c15ec116a7ada952d8457d50902c970616ef5 (refs/remotes/origin/trunk)
Checked out HEAD:
https://localhost/svn/test/project3/trunk r2
我希望看到A和B的两个版本,但在这两种情况下只显示最终版本。 E.g。
> cd gittest
> git log --follow A
commit c71c15ec116a7ada952d8457d50902c970616ef5
Author: tanderson <tanderson@897fde24-c897-6841-ad7f-93f2e7295302>
Date: Thu Apr 16 09:37:33 2015 +0000
project restructure
git-svn-id: https://localhost/svn/test/project3/trunk@2 897fde24-c897-6841-ad7f-93f2e7295302
我尝试过以下工具:
答案 0 :(得分:0)
是的,它可以。有用于此目的的工具。
一个常见工具是https://github.com/nirvdrum/svn2git。它将完整的svn历史翻译为git。
答案 1 :(得分:0)
在上面的简单测试存储库中,svn-all-fast-export可以正常工作。
它是用C ++编写的,并没有二进制文件。我能够使用cygwin构建它。
要隐藏上面的示例svn存储库:
创建一个规则文件rules.txt来指示svn-fast-all-export如何处理存储库路径:
create repository testnew
end repository
match /project1/trunk/
repository testnew
branch project1
end match
match /project2/trunk/
repository testnew
branch project2
end match
match /project3/trunk/
repository testnew
branch master
end match
执行命令
svn-all-fast-export --identity-map=users.txt --rules=rules.txt --stats /path/to/repo/test.svn
这将在当前目录中创建一个git存储库 testnew 。 git log 命令显示A和B的两个版本。例如:
> git log A
commit eb561b48109620fc64f9f7cf15a752b1730f8d18
Merge: e3a02bf e1cc2a9
Author: tanderson <tanderson@localhost>
Date: Sun May 24 06:00:36 2015 +0000
project restructure
commit e3a02bff6a7ace21b3789c4f9350e969add44541
Author: tanderson <tanderson@localhost>
Date: Sun May 24 06:00:35 2015 +0000
initial commit