当没有其他丢失的对象时,在 Git 中重建松散的丢失树 [英] Rebuild loose missing tree in Git when there are no other missing objects
问题描述
我的 Git 存储库声称存在损坏的对象:运行 git fsck --full
表示存储库中有损坏的松散对象.由于对象已损坏,我无法使用 git cat-file -t
对其进行解压缩,但是删除文件会导致 fsck 仅报告:
My Git repository claims there is a corrupted object: running git fsck --full
says that there's a corrupted loose object in the repo. Since the object is corrupted, I can't unpack it using git cat-file -t
, but removing the file causes fsck to report only:
broken link from tree 93e54230ef...
to tree 5aec4ad...
missing tree 5aec4ad...
我认为这个丢失的树是唯一丢失的文件,或者说没有悬空的提交/blob,因为运行 git ls-tree 93e54230ef...
只显示一行:<代码>040000 树 5aec4ad... android.此外,损坏文件的最后修改日期是昨天,从那时起我没有进行任何更改.不幸的是,我已经检查了我拥有的这个存储库的克隆,但它们都没有打包或解压丢失的对象.
I think this missing tree is the only file that is missing, or rather that there are no dangling commits/blobs, because running git ls-tree 93e54230ef...
shows only one line: 040000 tree 5aec4ad... android
. Also, the last-modified date on the corrupted file is yesterday, and I haven't made any changes since then. Unfortunately, I've checked the clones I have of this repository, but none of them have the missing object packed or unpacked.
如何在没有悬空提交或 blob 的情况下重建丢失的 git 树?
推荐答案
当 Git 中缺少的只是一棵树时,解决方案就是使用 write-tree:
When all that is missing in Git is a tree, the solution is simply to use write-tree:
git write-tree
执行该命令后,Git 存储库应恢复到以前的状态.
After executing that command, the Git repository should revert to its previous state.
这篇关于当没有其他丢失的对象时,在 Git 中重建松散的丢失树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!