当我尝试提交更改时,我得到这个错误:

error: object file .git/objects/31/65329bb680e30595f242b7c4d8406ca63eeab0 is empty
fatal: loose object 3165329bb680e30595f242b7c4d8406ca63eeab0 (stored in .git/objects/31/65329bb680e30595f242b7c4d8406ca63eeab0) is corrupt

我尝试了我得到的 git fsck:

error: object file .git/objects/03/dfd60a4809a3ba7023cbf098eb322d08630b71 is empty
fatal: loose object 03dfd60a4809a3ba7023cbf098eb322d08630b71 (stored in .git/objects/03/dfd60a4809a3ba7023cbf098eb322d08630b71) is corrupt

如何解决这个错误?


当前回答

这种情况也经常发生在我身上。我没有制定具体何时发生这种情况的协议,但我怀疑每当我的虚拟机(VM)“意外”存在时就会发生这种情况。如果我关闭虚拟机窗口(我使用的是Ubuntu 18.04 (Bionic Beaver))并重新开始,事情总是(?)工作。但是如果当我的笔记本电脑关闭(Windows主机系统)时,虚拟机窗口仍然打开,那么我经常遇到这个问题。

对于这里给出的所有答案:

thank you - they are very useful; I usually save a local copy of my code, restore the repository from remote, and move the backup copy back into the local folder. as the underlying problem is not really a Git issue, but rather a VM and/or Linux issue, I wonder if there shouldn't be a way to cure the reason rather the symptoms? Doesn't this kind of error indicate that some file system changes are not "applied" in any reasonable time, but only cached? (see for example Are file edits in Linux directly saved into disk?) -- to me it appears as if virtual Linux machines don't fsynch their stuff frequently enough. Whether this is an issue of Oracle's VirtualBox (which otherwise works very nicely) or of the guest file system, or of some settings, which we all overlook, is beyond my expertise. But I would be happy if someone could shed light on this.

其他回答

我只是有同样的问题:在拉远存储库后,当我做了一个git状态,我得到:

"错误:目标文件(…)为空" “致命的:松动的物体(…)已损坏”

我解决这个问题的方法是:

git藏 错误地删除Git文件(我不确定这是必要的) Git仓库清空

我不知道到底发生了什么,但这些指示似乎让一切都变得干净了。

事实上,我也有同样的问题。

在尝试此操作之前,请准备一份代码副本。

我刚刚做了 git重置头~

我的最后一次承诺也没有兑现。然后我又犯了一次,问题就解决了!

在这种情况下,我通过遵循这个问题来解决我的问题。

从存储库目录中删除。git文件夹。(为安全起见保留备份) 克隆我的回购在另一个目录。 从新的克隆目录复制.git文件夹。 粘贴到之前出现问题的目录中。

检查git状态,希望你能看到你所有的变化。现在你可以承诺并推进了。

修复git对象错误解决方案 只需运行以下命令

find .git/objects/ -size 0 -exec rm -f {} \;
git fetch origin



Refresh index: 100% (5322/5322), done.
error: object file .git/objects/d4/f989f0e5f4613a3cbba836b3c77dfb71a7a56c is empty
error: object file .git/objects/d4/f989f0e5f4613a3cbba836b3c77dfb71a7a56c is empty
error: object file .git/objects/d4/f989f0e5f4613a3cbba836b3c77dfb71a7a56c is empty
fatal: loose object d4f989f0e5f4613a3cbba836b3c77dfb71a7a56c (stored in .git/objects/d4/f989f0e5f4613a3cbba836b3c77dfb71a7a56c) is corrupt

我修复了我的git错误:对象文件是空的:

保存我上次成功提交/推送后编辑的所有文件的副本, 删除并重新克隆我的存储库, 用我编辑过的文件替换旧文件。