GitHub: 致命错误:协议错误:意外能力^{} - 如何诊断和治疗?

4
我在GitHub上有一个空的私有存储库,我可以正常从网页访问。
当我尝试推送一些我已经在本地完成的历史记录时,出现以下错误:
fatal: protocol error: unexpected capabilities^{}

谷歌搜索显示,过去它意味着服务器不支持SHA256,但那是9年前的事了。今天可能会出什么问题呢?
如何诊断这个问题?
有什么解决办法吗?
我正在使用来自Ubuntu 22.04的git版本2.34.1。
编辑:根据@VonC的回答,我将git升级到2.42.0版本。现在的消息已经改变为:
fatal: the receiving end does not support this repository's hash algorithm

完全没有帮助解决本地仓库的问题。日志中的哈希值有64个字符长。

2个回答

4

我在使用Eclipse/JGit时见过那个错误消息,就像我在JGit: 包写入错误(包括 Refs 时)中解释的那样。

这个补丁解释了:

The cause is that, since v3.1.0.201309270735-rc1~22 (Advertise capabilities with no refs in upload service., 2013-08-08), JGit's ref advertisement includes a ref named capabilities^{} to advertise its capabilities on, while git's ref advertisement is empty in this case. This allows the client to learn about the server's capabilities and is needed, for example, for fetch-by-sha1 to work when no refs are advertised.

This also affects "ls-remote". For example, against an empty repository served by JGit:

$ git ls-remote git://localhost/tmp/empty
0000000000000000000000000000000000000000        capabilities^{}

Git advertises the same capabilities^{} ref in its ref advertisement for push, but since it never did so for fetch, the client didn't need to handle this case.

首先检查推送是否来自Eclipse(它不会使用系统的Git), 然后检查是否只需要升级Git(命令行)。

不,我还没有使用过Eclipse。第一次提交可能是在VSCode中完成的。看看我的编辑,在将git升级到2.42.0之后有什么变化。我仍然需要处理这个存储库以找到解决办法,因为在这种新情况下,Google完全无能为力。 谢谢。 - Michał Fita
@MichałFita 你能开启TRACE2吗?以防它有一些线索。(GIT_TRACE2GIT_TRACE2_EVENT - VonC
这个问题的用户体验很糟糕 - 最后我自己找到了答案。GitHub不接受版本号为1和SHA256格式的仓库推送。在2023年...太棒了,真是太棒了。 - Michał Fita
@MichałFita 很好的发现,已点赞。我在这里写了关于SHA256的内容(https://dev59.com/hF4c5IYBdhLWcg3wOoK6#47838703)和(https://dev59.com/b1IH5IYBdhLWcg3wVMWj#60088126)。Git 2.43删除了实验性状态 - VonC

2
问题似乎是在新的git中出现了错误:
fatal: the receiving end does not support this repository's hash algorithm

这是由于一个简单的事实,即GitHub在2023年仍不支持具有SHA256提交的存储库版本格式1(遗憾的是GitLab也是如此)。

当我通过对每个提交进行“format-patch”并在具有格式版本0的新存储库上使用“git am”来“重写”历史时(我还必须重新创建标签),然后我成功地推送了。

现在,关于我的存储库最初是如何创建为版本1的,我不知道/记得 - 我想它可能是裸的“git init”,但也可能是其他东西(可能性包括“cargo”和VSCode)。

你已经被警告了。希望这个答案(在撰写时有效)能帮助其他通过谷歌搜索这个问题的人。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接