从svn迁移到git时保留所有历史记录

3
当从svn迁移到git时,是否可以保留所有历史记录?我发现在< strong> svn copy 之前的历史记录会丢失。
我有以下svn存储库:
项目1 / trunk / A 项目2 / trunk / dir / B 项目3 / trunk A - 从项目1复制 dir / B - 从项目2复制
如果我使用git svn克隆项目3,则来自项目1和项目2的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的所有修订版本,但是在这两种情况下,只显示了最终的修订版本。例如:
> 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

我尝试了以下工具:

2个回答

0

在上面的简单测试存储库中,svn-all-fast-export 可以工作。

它是用 C++ 编写的,没有二进制文件。我能够使用 cygwin 构建它。

要转换上面的示例 svn 存储库:

  1. 将svn仓库本地复制(使用svnadmin hotcopy或svnsync)
  2. 根据https://git-scm.com/book/en/v2/Git-and-Other-Systems-Migrating-to-Git创建一个作者文件users.txt
  3. 创建一个规则文件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
    
  4. 运行:

    svn-all-fast-export --identity-map=users.txt --rules=rules.txt --stats /path/to/repo/test.svn
    

这将在当前目录中创建一个名为testnew的git仓库。 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 

0

谢谢,但我在使用svn2git时遇到了同样的问题,即git log命令只列出了svn复制之后的历史记录。 - tanderson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接