gpt4 book ai didi

git fast-import --export-marks 标志

转载 作者:太空狗 更新时间:2023-10-29 14:09:28 26 4
gpt4 key购买 nike

git fast-import --export-marks 能够导出将标记与其创建的提交哈希相关联的文件。

到目前为止,我看到的标记不是输入中提供的标记,而是一些与输入无关的“内部标记”。

如果它保留原始标记,对于导入/导出互操作来说不是更好吗?

最佳答案

fast-import 标记exported 的目的是列出提交和 blob,以供后续验证和同步。 fast-import 标记imported 的目的是在增量导出-导入场景中跳过提交。

╔════════════════╦══════════════════════════════════╗║                ║        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)  ║╚════════════════╩══════════════════════════════════════╝

You can see from the tables above how the flags might be combined in a scenario where repos are incrementally synchronised. One might export a repo, import it elsewhere, then either create incremental export files by skipping previously exported commits, or create full exports and incrementally import by skipping commits already known.

Here's a short example to clarify.

$ 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

只导出了一个标记,添加到 repo 的单个提交的标记。

$ git show 610432e74c554d783ff5f9edd1bb18548d68e533
commit 610432e74c554d783ff5f9edd1bb18548d68e533
...

当您继续重新创建存储库时,导出的标记不仅会列出提交,还会列出新的 blob。这些新的 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

blob :1 已重新创建并在标记文件中新列出(使用恰好是 :1 的第一个可用标记),但请注意marked commit :2 保留了它的标记和来自原始导出 repo 的哈希。

关于git fast-import --export-marks 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5451634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com