git fast-import --export-marks能够导出一个文件,将标记与它创建的提交哈希相关联。git fast-import --export-marks标志
到目前为止,我已经看到标记不是输入中提供的标记,而是一些与输入无关的“内部标记”。
对于导入/导出互操作性,如果它保留原始标记,会不会更好?
git fast-import --export-marks能够导出一个文件,将标记与它创建的提交哈希相关联。git fast-import --export-marks标志
到目前为止,我已经看到标记不是输入中提供的标记,而是一些与输入无关的“内部标记”。
对于导入/导出互操作性,如果它保留原始标记,会不会更好?
标记出口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
保留了它的标志,它的哈希从原来的团块出口回购。
是什么让你觉得(或你有什么证据)'git fast-import'不会导出它从输入流接收到的标记? – kynan 2013-03-20 00:25:25
参见https://github.com/git/git/commit/28c7b1f7b7b70013c2f380c2d720d0c918d3d83a – VonC 2015-08-16 20:57:17