2011-03-27 69 views
3

git fast-import --export-marks能夠導出一個文件,將標記與它創建的提交哈希相關聯。git fast-import --export-marks標誌

到目前爲止,我已經看到標記不是輸入中提供的標記,而是一些與輸入無關的「內部標記」。

對於導入/導出互操作性,如果它保留原始標記,會不會更好?

+0

是什麼讓你覺得(或你有什麼證據)'git fast-import'不會導出它從輸入流接收到的標記? – kynan 2013-03-20 00:25:25

+0

參見https://github.com/git/git/commit/28c7b1f7b7b70013c2f380c2d720d0c918d3d83a – VonC 2015-08-16 20:57:17

回答

2

標記出口fast-import的目的是列出提交和blob以供後續驗證和同步。標記的目的是通過fast-import導入來跳過增量導出導入場景中的提交。

 
╔════════════════╦══════════════════════════════════╗ 
║    ║  git fast-export   ║ 
╠════════════════╬══════════════════════════════════╣ 
║ --import-marks ║ 1) commits to skip during export ║ 
║ --export-marks ║ 2) exported commits    ║ 
╚════════════════╩══════════════════════════════════╝ 
╔════════════════╦══════════════════════════════════════╗ 
║    ║   git fast-import    ║ 
╠════════════════╬══════════════════════════════════════╣ 
║ --import-marks ║ 3) commits to skip during import  ║ 
║ --export-marks ║ 4) a) blobs       ║ 
║    ║ b) imported commits, same as (2) ║ 
╚════════════════╩══════════════════════════════════════╝ 

您可以從上面的表中看到,在回購增量同步的情況下,這些標記可能如何組合。你可以導出一個倉庫,將它導入到其他地方,然後通過跳過先前導出的提交來創建增量導出文件,或者通過跳過已知的提交來創建完全導出和增量導入。

下面是一個簡短的例子來說明。

$ cd /tmp && git init example && cd example && touch README && \ 
git add README && git commit -m "first commit" 
$ git fast-export --all --export-marks=/tmp/example-repo.marks > /tmp/example-repo.export 
--- /tmp/example-repo.export --- 
blob 
mark :1 
... 
reset refs/heads/master 
commit refs/heads/master 
mark :2 
... 
reset refs/heads/master 
from :2 

--- /tmp/example-repo.marks --- 
:2 610432e74c554d783ff5f9edd1bb18548d68e533 

只導出一個標記,單個提交的標記添加到回購。

$ git show 610432e74c554d783ff5f9edd1bb18548d68e533 
commit 610432e74c554d783ff5f9edd1bb18548d68e533 
... 

當您繼續重新創建存儲庫時,導出的標記不僅會列出提交,還會列出新的blob。這些新的斑點已經被重新創建,並且出現在標記中供您檢查,提交也被列出來與所有導入引用的提交進行比較。

$ cd /tmp && git init example-import && cd example-import && \ 
cat /tmp/example-repo.export | git fast-import --export-marks=/tmp/example-import-repo.marks 

--- /tmp/example-import-repo.marks --- 
:1 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 
:2 610432e74c554d783ff5f9edd1bb18548d68e533 

:1已經重建,並在標記文件是新上市(使用第一個可用的標誌,它恰好是:1),但要注意的顯着承諾:2保留了它的標誌,它的哈希從原來的團塊出口回購。