Rebuild loose missing tree in Git when there are no other missing objects

可紊 提交于 2020-01-25 06:14:31

问题


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...

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.

How can I rebuild a missing git tree with no dangling commits or blobs?


回答1:


When all that is missing in Git is a tree, the solution is simply to use write-tree:

git write-tree

After executing that command, the Git repository should revert to its previous state.



来源:https://stackoverflow.com/questions/11639751/rebuild-loose-missing-tree-in-git-when-there-are-no-other-missing-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!