每当我从我的遥控器,我得到以下关于压缩的错误。当我运行手动压缩,我得到相同的:

$ git gc
error: Could not read 3813783126d41a3200b35b6681357c213352ab31
fatal: bad tree object 3813783126d41a3200b35b6681357c213352ab31
error: failed to run repack

有人知道该怎么做吗?

从cat文件中我得到了这个:

$ git cat-file -t 3813783126d41a3200b35b6681357c213352ab31
error: unable to find 3813783126d41a3200b35b6681357c213352ab31
fatal: git cat-file 3813783126d41a3200b35b6681357c213352ab31: bad file

从git fsck中我得到了这个(不知道它是否真的相关):

$ git fsck
error: inflate: data stream error (invalid distance too far back)
error: corrupt loose object '45ba4ceb93bc812ef20a6630bb27e9e0b33a012a'
fatal: loose object 45ba4ceb93bc812ef20a6630bb27e9e0b33a012a (stored in .git/objects/45/ba4ceb93bc812ef20a6630bb27e9e0b33a012a) is corrupted

有人能帮我解读一下吗?


当前回答

我在一台Windows 10电脑上遇到了类似的问题,其中一个驱动器备份了我的文档文件夹,其中有我的git存储库。

查看git对象目录中的对象,我没有看到绿色的复选标记,而是该文件的蓝色同步图标。所有其他目标文件似乎都有绿色的复选标记。玩周围,尝试的东西,我尝试选择选项始终保持此文件夹在此设备上,但得到一个错误:错误0x80071129标签存在于重解析点缓冲区是无效的。

这个链接(https://answers.microsoft.com/en-us/msoffice/forum/all/error-0x80071129-the-tag-present-in-the-reparse/b8011cee-98c5-4c33-ba99-d0eec7c535a0)建议以管理员身份运行chkdsk /r /f来解决这个问题(必须重新启动计算机)。我这么做了,问题就解决了。

其他回答

在虚拟机上工作,在我的笔记本上,电池没电了,得到这个错误;

error: object file .git/objects/ce/theRef为空 文件.git/objects/ce/theRef是空的 (存储在.git/objects/ce/theRef中)已损坏

我设法让回购工作再次只有2个命令,而没有丢失我的工作(修改文件/未提交的更改)

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

在那之后,我运行了git状态,回购很好,有我的更改(等待提交,现在就做…)

Git版本1.9.1

请记住备份您所记得的所有更改,以防此解决方案不起作用,需要更激进的方法。

我刚遇到过这样的问题。我的特殊问题是由系统崩溃引起的,它破坏了最近的提交(因此也破坏了主分支)。我没有强迫自己,想要重新做出承诺。在我的特殊情况下,我可以这样处理:

Make a backup of .git/: rsync -a .git/ git-bak/ Check .git/logs/HEAD, and find the last line with a valid commit ID. For me, this was the second most recent commit. This was good, because I still had the working directory versions of the file, and so the every version I wanted. Make a branch at that commit: git branch temp <commit-id> re-do the broken commit with the files in the working directory. git reset master temp to move the master branch to the new commit you made in step 2. git checkout master and check that it looks right with git log. git branch -d temp. git fsck --full, and it should now be safe to delete any corrupted objects that fsck finds. If it all looks good, try pushing. If that works,

这对我很管用。我怀疑这是一个相当常见的场景,因为最近的提交是最有可能被损坏的,但如果你丢失了一个更早的提交,你可能仍然可以使用这样的方法,小心地使用git cherrypick,并在.git/logs/HEAD中reflog。

当我遇到这个问题时,我备份了我最近的更改(因为我知道我已经更改了什么),然后删除了它在.git/location中抱怨的文件。然后我做了一个“少不再来”的动作。不过要小心,这可能不适合你。

我是这样解决的: 我决定简单地将未损坏的对象文件从备份的克隆复制到原始存储库。这个方法同样有效。(顺便说一下:如果你在.git/objects/中找不到它的名字,它可能已经被[打包][包]以节省空间。)

这似乎是Dropbox或符号链接文件夹出Dropbox为我的一个问题。其他类似的服务可能也是如此。当我去git push时,我会得到腐败松散对象错误。对我来说,在macOS Big Sur上,修复方法只是将回购的递归副本复制到Dropbox之外的目录中。我相信这导致Dropbox为损坏的动态引用拉出实时文件。复制后,我立即能够git推送没有错误。