sheldon_blogs

Git : error: object file xxx is empty 错误修复方法

git log发现如下错误信息:

error: object file .git/objects/20/6e7330a25fe1f1e533b5f769103e37e2a5c7f4 is empty
error: object file .git/objects/20/6e7330a25fe1f1e533b5f769103e37e2a5c7f4 is empty
fatal: loose object 206e7330a25fe1f1e533b5f769103e37e2a5c7f4 (stored in .git/objects/20/6e7330a25fe1f1e533b5f769103e37e2a5c7f4) is corrupt

修复指令:

find .git/objects/ -type f -empty | xargs rm
git fetch -p
git fsck --full

 

 说明:

 该方法首先会删除导致仓库报错的空对象文件,然后从远程存储库获取丢失的最新文件,然后执行完整的文件存储检查。此方法基本会成功而没有任何错误(尽管仍然可能有一些警告!), 所以使用该方法要保证远程仓库是完整的,以此来修复本地破损的存储仓库,否则该方法就不适用了

posted on 2021-06-16 13:55  sheldon_blogs  阅读(1374)  评论(0编辑  收藏  举报

导航