自Windows上更新了git版本之后,git pull 出错,关键字: “cannot lock ref”, “unable to resolve reference”, “reference broken”, “unable to update local ref”.

$ git pull
error: cannot lock ref 'refs/remotes/origin/xxx/yyy/zzz': unable to resolve reference 'refs/remotes/origin/xxx/yyy/zzz': reference broken
From <repo>
 ! [new branch]            xxx/yyy/zzz -> origin/xxx/yyy/zzz  (unable to update local ref)

为大家少走弯路,将尝试过的几个方法都一一列出。

网上解决方法-1:

git gc --prune=now
git remote prune origin

无效,git pull仍然失败。

网上解决方法-2:

git update-ref -d refs/remotes/origin/xxx/yyy/zzz

无效,git pull仍然失败。

网上解决方法-3:

rm .git/logs/refs/remotes/origin/xxx/yyy/zzz 

成功解决。

xxx/yyy/zzz 是一个别人的branch的名字,本人从来没有用过。
这里暂不深究git原理了。本篇到此为止。

(完)

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐