繁体   English   中英

Git 拉包文件给出“致命:找不到远程参考头”

[英]Git pull bundle file gives 'fatal: Couldn't find remote ref HEAD'

我发布了一个自我回答,因为我知道我的一些同事很快就会在谷歌上搜索。 我们有时需要分发以 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 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命令将第二个参数指定为分支之一,即 output,在您的情况下为“feature/aunit_reporters”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM