【问题标题】:Git pull bundle file gives 'fatal: Couldn't find remote ref HEAD'Git拉包文件给出'致命:找不到远程参考头'
【发布时间】:2020-11-25 09:33:13
【问题描述】:

我发布一个自我回答是因为我知道我的一些同事很快就会在谷歌上搜索这个问题。我们有时需要分发以 master 为基线的捆绑文件,因此仅包含创建时明确包含的特定分支。例如,分销商这样做:

git bundle create ../file.gitbundle master..feature/aunit_reporters

问题是,在收到捆绑文件后,执行git pull ../file.gitbundle 给出:

fatal: Couldn't find remote ref HEAD

我已通过以下方式验证了捆绑文件应该适用:

git bundle verify ../file.gitbundle
The bundle contains this ref:
4f969119b208b71f4893222810600862 refs/heads/feature/aunit_reporters
The bundle requires this ref:
fd9801b79b56f5dd55ab1e6500f16daf

并且git show fd9801b79b56f5dd55ab1e6500f16daf 正确显示了所需的提交,而不是提供fatal: ambiguous argument '[commit-hash]': unknown revision or path not in the working tree,这表明我没有必要的基线提交。

【问题讨论】:

    标签: git git-bundle


    【解决方案1】:
    git pull ../file.gitbundle feature/aunit_reporters
    

    git pull [remote] 的第二个参数是可选的,默认为“HEAD”。无论您是否使用捆绑文件都是这种情况,但通常真实的 git 存储库(本地和托管)有一个指向某处的 HEAD,因此默认值有效。部分捆绑文件可能没有这个;分销商确实应该添加 HEAD,以允许定期拉动:

    git bundle create ../file.gitbundle master..feature/aunit_reporters feature/aunit_reporters HEAD
    

    (不幸的是,您现在必须指定两次分支名称,否则您会得到一个分离的 HEAD 存储库,这同样会让收件人感到困惑)

    解决方案是将第二个参数指定为git bundle verify 命令输出的分支之一,在您的情况下为“feature/aunit_reporters”。

    【讨论】:

    • 我相信你已经找到了解决方案,但你的答案提到了不同的分支feature/combined_reporter 与你的问题feature/aunit_reporters相比
    • 感谢@hultqvist,这确实令人困惑。我还添加了自写此答案以来学到的另一个技巧。
    猜你喜欢
    • 1970-01-01
    • 2014-08-18
    • 2012-12-12
    • 2012-10-08
    • 1970-01-01
    • 2022-10-24
    • 2015-03-07
    • 2021-07-16
    • 1970-01-01
    相关资源
    最近更新 更多