如何处理这个git错误 [英] How to deal with this git error
问题描述
22:09:15 $ git status
#在分支主
错误:无法读取8124cc15c63be92d534e4cdfa33c38d54deee122
错误:无法读取树对象HEAD
没有提交(工作目录干净)
Google搜索错误:无法读取树对象HEAD
不会产生太多帮助,错误似乎非常罕见。我不知道如何处理它。这可能是硬盘驱动器故障吗?
编辑:
git fsck
如下:
从提交607328dc80e4901a55b95c683d4fbf43e6df28bf
断开链接到树8124cc15c63be92d534e4cdfa33c38d54deee122
缺少树8124cc15c63be92d534e4cdfa33c38d54deee122
dangling tree 56b5d4a5e429d251582ec927bca7ef1225510c41
dangling tree 0259d2d38b18b6136bb6070fb41faf3624453cc6
在断开的链接消息中,您可以按照 GitFaq 建议:
- 备份您的所有状态,如果你损坏了更多的东西,你所做的任何事情都是可重做的!
man git-unpack-obj ects
,特别是-r
标志。
另请注意,它仅解包对象并不是已经可用的,所以你需要首先将包文件从它的正常位置移开(否则git-unpack-objects
将会找到包中的所有对象文件本身并不打开任何东西)
替换任何损坏和/或丢失的对象
- 这是一个具有挑战性的部分。
有时(希望经常!)您可以在其他版本库中找到缺失的对象。
在其他时候,您可能需要尝试以某种其他方式查找数据(例如,也许您的签出副本包含文件内容,散列时将是缺失的对象?)。
确保一切都很满意 git fsck --full
重新包装所有内容以再次返回有效状态
注意: 2016年7月更新(7年过去了),Git 2.10即将发布,您现在拥有: 它有助于命名这些损坏的链接的来源 请参阅如何解决从树到树的git错误断开连接?以获取更多信息。
(2012年2月更新:这些插件已经走过了很长的一段路,现在相当稳定)
git fsck --name-objects
I am getting this error in my git repository:
22:09:15 $ git status
# On branch master
error: Could not read 8124cc15c63be92d534e4cdfa33c38d54deee122
error: unable to read tree object HEAD
nothing to commit (working directory clean)
A Google search for error: unable to read tree object HEAD
doesn't result in much help, this error seems to be very rare. I am not sure how to deal with it. Could it be a hard drive failure?
Edit:
The output of git fsck
is the following:
broken link from commit 607328dc80e4901a55b95c683d4fbf43e6df28bf
to tree 8124cc15c63be92d534e4cdfa33c38d54deee122
missing tree 8124cc15c63be92d534e4cdfa33c38d54deee122
dangling tree 56b5d4a5e429d251582ec927bca7ef1225510c41
dangling tree 0259d2d38b18b6136bb6070fb41faf3624453cc6
On a "broken link" message, you could follow the GitFaq recommendations:
- back up all your state so that anything you do is re-doable if you corrupt things more!
- explode any corrupt pack-files
- See "
man git-unpack-objects
", and in particular the "-r
" flag.
Also, please realize that it only unpacks objects that aren't already available, so you need to move the pack-file away from its normal location first (otherwisegit-unpack-objects
will find all objects that are in the pack-file in the pack-file itself, and not unpack anything at all)- replace any broken and/or missing objects
- This is the challenging part.
Sometimes (hopefully often!) you can find the missing objects in other copies of the repositories.
At other times, you may need to try to find the data some other way (for example, maybe your checked-out copy contains the file content that when hashed will be the missing object?).- make sure everything is happy with "
git fsck --full
"- repack everything to get back to an efficient state again
Notes:
- missing objects can also be related to alternate (when you share objects between repositories) with git alternates (even though that can be risky).
- The JGit/Egit eclipse plugin is also known to have a few issues.
(Update February 2012: those plugins have come a long way and are now quite stable)
Update July 2016 (7 years laters), with Git 2.10 soon to be released, you now have:
git fsck --name-objects
It helps naming the origin of those broken links
See "How to fix git error broken link from tree to tree?" for more.
这篇关于如何处理这个git错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!