修复一个损坏的松散对象作为git中的提交 [英] fixing a corrupt loose object as a commit in git
问题描述
user @ thismachine:〜/ file / path $ git add *
user @ thismachine:〜/ file / path $ git push
$ C
user @ thismachine:〜/ file / path $ git commit -mmy commitmesg
(我惊慌失措,因为在推送之前我忘了添加一个提交,所以我用cntrl + c'ed它。
现在,我从git fsck -full收到以下错误:
error:inflate :数据流错误(不正确的报头校验)
错误:腐败松散对象 '5cdeb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a'
致命:松散对象5cdeb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a(存储在的.git /对象/ 5C / deb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a)
$ C
$ git cat-file -t 5cdeb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a返回这个对象是一个提交。
搜索后,我发现如果对象是 blob ,但如果是提交则不会。
解决方案 http://vincesalvino.blogspot.ca/2013/08/git-empty-files-corrupt-objects-and.html 允许我解决这个问题:
pre $ find $ .git / objects / -size 0 -exec rm -f {} \;
Immediately before receiving this error I did the following:
user@thismachine:~/file/path$ git add *
user@thismachine:~/file/path$ git push
^C
user@thismachine:~/file/path$ git commit -m "my commitmesg"
(I panicked because I forgot to add a commit before pushing, so I cntrl+c'ed it.
Now, I receive the following error from git fsck -full:
error: inflate: data stream error (incorrect header check)
error: corrupt loose object '5cdeb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a'
fatal: loose object 5cdeb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a (stored in .git/objects/5c/deb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a)
git cat-file -t 5cdeb9c3a1fe164cb4d2779d1e0d9d9f4ef18c6a returns that this object is a commit.
After searching, I've found how fix this if the object is a blob but not if it's a commit.
A solution from http://vincesalvino.blogspot.ca/2013/08/git-empty-files-corrupt-objects-and.html allowed me to fix the problem:
find .git/objects/ -size 0 -exec rm -f {} \;
这篇关于修复一个损坏的松散对象作为git中的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!