git: error: cannot lock ref, error: cannot lock ref

在执行git pull的时候会出现这样的错误:

$ git pull
error: cannot lock ref 'refs/remotes/origin/branch': 'refs/remotes/origin/branch/repair' exists; cannot create 'refs/remotes/origin/branch'
From git.microsoft.com:office2019/excel
 ! [new branch]        branch      -> origin/branch  (unable to update local ref)
error: some local refs could not be updated; try running
 'git remote prune origin' to remove any old, conflicting branches

解决办法就是根据提示执行:

git remote prune origin

我们知道当我们一个branch从push–>open–>approve–>merge,大致都要经过这几个过程,当我们一个branch被merge到master以后,我们就要求会删除github上的branch,但是我们本地的branch却一般没人管,时间长了,本地的branch就会积累一堆,这个命令就是将本地还没有删除的branch一起清除掉。

你可能感兴趣的:(git,GitHub)