Git - 损坏的对象?

发布于 2024-11-03 00:44:19 字数 647 浏览 1 评论 0原文

我的房子刚刚停电,现在我的 git 存储库(发生这种情况时我正在提交)正在报告:

user@localhost$ git fsck
fatal: object 192e0282d23863ec80375a77011012ef8cb80f77 is corrupted

由于此错误,我无法提交。拉动和抓取似乎仍然工作正常。

user@localhost$ git commit
error: unable to find 192e0282d23863ec80375a77011012ef8cb80f77
fatal: 192e0282d23863ec80375a77011012ef8cb80f77 is not a valid object

我尝试重置它,但没有任何作用

git reset HEAD 192e0282d23863ec80375a77011012ef8cb80f77
git gc

我该如何解决这个问题?

更新: 文件仍然没问题,所以我只是克隆了存储库的一个新实例并手动将文件移动过来(很高兴这不是唯一的存储库实例!)。不过,我保留了损坏的存储库,以便我可以尝试在此处发布的修复,以防下次

My house just suffered a power-outage and now my git repo (which I was committing to when it happended) is reporting:

user@localhost$ git fsck
fatal: object 192e0282d23863ec80375a77011012ef8cb80f77 is corrupted

I can't commit because of this error. Pulling and fetching still seems to work fine.

user@localhost$ git commit
error: unable to find 192e0282d23863ec80375a77011012ef8cb80f77
fatal: 192e0282d23863ec80375a77011012ef8cb80f77 is not a valid object

I tried reseting it, but it didn't do anything

git reset HEAD 192e0282d23863ec80375a77011012ef8cb80f77
git gc

How do I fix this?

UPDATE: The files were still fine so I just cloned a new instance of the repo and manually moved the files over (Glad this wasn't the only repo instance!). However, I kept the broken repo so that I can try fixes posted here in case there is a next time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

dawn曙光 2024-11-10 00:44:19

如果您正在寻找有关如何从中恢复的建议,请参阅此线程:如何恢复 git 存储库中损坏的对象(对于新手)?

If you are looking for suggestions on how to recover from this, see this thread: How do you restore a corrupted object in a git repository (for newbies)?

只是一片海 2024-11-10 00:44:19

实际上,您对新克隆所做的操作可能是修复它的推荐方法。如果没有必要,做复杂的事情是没有意义的。如果您的工作树中没有正确的版本并且没有另一个干净的副本,那么这些指南更适合您。

无论如何,我认为您想重置到断电之前的最后一次提交,将损坏的对象移出 .git/objects,然后重试。看来您的树可能已损坏,这就是为什么针对恢复斑点的方法没有帮助的原因。

Actually what you did with a new clone is probably the recommended way to fix it. No sense doing something complex if you don't have to. Those howtos are more for if you don't have the right version already in your working tree and don't have another clean copy.

Anyway, I think you wanted to reset to your last commit before the power outage, move the corrupted object out of your .git/objects, and try again. It looks like your tree might have been corrupted, which is why the howtos geared towards recovering blobs didn't help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文