簡體   English   中英

從svn轉到git時保留所有歷史記錄

[英]Keeping all history when moving from svn to git

從svn轉到git時,是否可以保留所有歷史記錄? 我發現svn副本之前的歷史記錄丟失了。

我有以下svn存儲庫:

  • PROJECT1 /中繼線/ A
  • 項目2 /中繼/ DIR / B
  • 項目3 /后備箱
    • A - 從project1復制
    • dir / B - 從project2復制

如果我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日志顯示兩個修訂:

> 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

我嘗試了以下工具:

是的,它可以。 有用於此目的的工具。

一個常見的工具是https://github.com/nirvdrum/svn2git 它將完整的svn歷史轉換為git。

在上面的簡單測試存儲庫中, 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 

這將在當前目錄中創建一個git存儲庫testnew git log命令顯示A和BEg的兩個修訂:

> 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 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM