git pull断电,提示松散对象已损坏


问题描述

itaken@itaken-home:~/path/to/project$ git status
error: 对象文件 .git/objects/ba/c013919d838f7213880dxxxx670329927c8a1e
error: 对象文件 .git/objects/ba/869aeb889bcc13e079fbxxxx2605a69dd283d6
fatal: 松散对象 d8472d182b537e7xxxxx612ec795d08c6242a8(.git/objects/ba/xxxx) 已损坏

解决方案

进入工作目录, 执行以下命令修复即可(根据仓库大小与commit次数,执行时间有所不同).

find .git/objects/ -size 0 -exec rm -f {} \;
git fetch origin

参考文档


Author: Itaken
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Itaken !
  TOC目录