git 致命:发现 SHA1 冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23964033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git fatal: SHA1 COLLISION FOUND
提问by ddinchev
I seem to have a corrupted repo that I have no idea how to fix...
我似乎有一个损坏的回购,我不知道如何修复......
$ git pull
remote: Counting objects: 141, done.
remote: Compressing objects: 100% (90/90), done.
error: unable to unpack ff7fca002656ad848c44bf134088d638a01d5217 header
error: inflateEnd: stream consistency error (no message)
fatal: SHA1 COLLISION FOUND WITH ff7fca002656ad848c44bf134088d638a01d5217 !
fatal: index-pack failed
Unable to write to standard output: The pipe is being closed.
And this is the output from the fsck
:
这是来自的输出fsck
:
$ git fsck
error: unable to unpack 024e257c1a13532e7d5579b0ea4bb5915d21e4a6 header
error: inflateEnd: stream consistency error (no message)
fatal: loose object 024e257c1a13532e7d5579b0ea4bb5915d21e4a6 (stored in super/sectet/path/to/repo/.git/objects/02/4e257c1a13532e7d5579b0ea4bb5915d21e4a6) is corrupt
Any ideas on how to approach this? I basically want to get whatever is in the remote and push my few commits on top of that.
关于如何解决这个问题的任何想法?我基本上想获取远程中的任何内容,并在此之上推送我的少数提交。
采纳答案by ddinchev
I think the repo got corrupted by either EGit or SourceTree (which I use in parallel) and has nothing to do with actually hash collisions. I solved it, as suggested by comments, by cloning the remote as a new repo, and copying my changes over.
我认为 repo 被 EGit 或 SourceTree(我并行使用)损坏,并且与实际的哈希冲突无关。我按照评论的建议解决了这个问题,方法是将遥控器克隆为新的存储库,然后复制我的更改。
回答by depperm
I ran into the same issue and ran:
我遇到了同样的问题并跑了:
git prune
git gc
which mentioned:
其中提到:
error: bad ref for refs/remotes/origin/ticketName
错误:refs/remotes/origin/ticketName 的错误引用
So i removed the reference and that fixed the issue:
所以我删除了参考并解决了问题:
rm .git/refs/remotes/origin/ticketName
回答by rfajarachmad
I have a similar issue and solved it by running:
我有一个类似的问题并通过运行解决了它:
$ git prune
Output: fatal: unable to parse object: refs/heads/prod-283
and just delete the reference above:
并删除上面的参考:
$ rm -f .git/refs/heads/prod-283
and finally I am able to run git pull
最后我可以跑了 git pull
回答by kumar
I ran the following commnads:
我运行了以下命令:
git prune
git gc
and removed file .git\refs\remotes\origin\master (the one listed in error: bad ref)
并删除文件 .git\refs\remotes\origin\master (错误中列出的那个:bad ref)
and ran
跑了
git gc --prune=now
which fixed the issue.
解决了这个问题。