在目前接受的答案没有帮助我,因为我没有在远程回购一个裁判删除-这纯粹是我的地方!因此,如果遇到这种情况,请执行以下操作:
这是我面临的问题:
$ git fetch origin
error: cannot lock ref 'refs/remotes/origin/fix/sub-branch':
'refs/remotes/origin/fix' exists; cannot create
'refs/remotes/origin/fix/sub-branch'
From <repo URL>
! [new branch] fix/sub-branch -> origin/fix/sub-branch
(unable to update local ref)
我尝试了接受的答案的建议,但得到了:
$ git push origin :fix
error: unable to delete 'fix': remote ref does not exist
error: failed to push some refs to <repo URL>
所以ref甚至不存在origin-显然它只是挂在我本地存储区的某个地方。所以我跑了$ git remote show me,产生了:
Remote branches:
...
refs/remotes/origin/fix stale (use 'git remote prune' to remove)
...
然后使解决方案变得清晰:
$ git remote prune origin
Pruning origin
URL: <redacted>
* [pruned] origin/fix
这样,问题就消失了:
$ git fetch origin
remote: Counting objects: 5, done.
remote: Total 5 (delta 2), reused 2 (delta 2), pack-reused 3
Unpacking objects: 100% (5/5), done.
From <repo URL>
* [new branch] fix/sub-branch -> origin/fix/sub-branch