git - 由于缺少对象,我该如何处理 Git 损坏?

标签 git corruption

我刚刚去克隆另一台远程服务器上的存储库,但在尝试这样做时遇到了问题:

git clone git@codebasehq.com:blah/blah/docs.git
Cloning into docs...
remote: Counting objects: 343, done.
remote: error: unable to find 14f87a739828e4d489b0310a51e057b30333926e
remote: Compressing objects: 100% (325/325), done.
error: git upload-pack: git-pack-objects died with error.   
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: fatal: unable to read 14f87a739828e4d489b0310a51e057b30333926e
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed

我做了一些研究,发现了关于 git fsck 的信息,这里是输出:

$ git fsck --full
error: sha1 mismatch 14f87a739828e4d489b0310a51e057b30333926e

error: 14f87a739828e4d489b0310a51e057b30333926e: object corrupt or missing
missing blob 14f87a739828e4d489b0310a51e057b30333926e

所有其他遇到类似问题的人都有链接断开问题或其他问题。我对 Git 还是很陌生,有人知道如何解决这个问题吗?

我仍然可以推送到我的中央远程存储库,但我无法克隆它。

14f87a739828e4d489b0310a51e057b30333926e 是一个 blob,它是存储库根目录中的 markdown 文件。我尝试删除此文件并推送这些更改无济于事。


编辑:是否可以从另一个仓库导入 git 历史记录?我在想我可以开始一个新的 repo 协议(protocol)并将我的文件复制到其中,然后导入提交历史记录。

最佳答案

如果它只是一个文件并且还没有打包,您应该能够在本地存储库的 .git/objects/14/f87a739828e4d489b0310a51e057b30333926e 中找到它。您可以将此文件复制到您服务器上存储库中的相应目录。

如果它已打包,您应该能够在 .git/objects/pack/ 中的其中一个打包文件上使用 git unpack-objects 将其解包。之后,复制到服务器的工作如上所述。

关于git - 由于缺少对象,我该如何处理 Git 损坏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4929674/

相关文章:

excel - Excel工作簿已损坏和已修复现在工作表说代码错误时内存不足

Git日志不包括分支

git - 搁置的 ChangeList 的 Perforce 命令行统一差异

git:你怎么可能在 git-status 中使用 `R` 、 `C` 和 `U` 标志

algorithm - 编码数据以处理损坏

visual-studio - VS损坏的.sln文件?

c++ - 为什么我的堆已损坏?

php - 从数据库中检索文件时文件已损坏

git - 如何安装 Gitlab 以在 Subgit 存储库上运行?

git - Julia git 错误