git运行突然提示 Auto packing the repository in background for optimum performance

git运行突然提示
Auto packing the repository in background for optimum performance.
See “git help gc” for manual housekeeping.
error: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.

fatal: object 0e6e9b9ea821b1f859f9e2cab931ad8c00194daf cannot be read
error: failed to run repack

查资料,原来是自己本地一些 “悬空对象”太多(git删除分支或者清空stash的时候,这些其实还没有真正删除,成为悬空对象,我们可以使用merge命令可以从中恢复一些文件)

解决:

1.输入命令:git fsck --lost-found,可以看到好多“dangling commit”
2.清空他们:git gc --prune=now,完成

 

Share