Die aktuell akzeptierte Antwort hat mir nicht geholfen, da ich keinen Ref auf dem Remote-Repo zum Löschen hatte - es war nur auf meinem lokalen! Wenn Sie sich in dieser Situation befinden, gehen Sie wie folgt vor:
Dies ist das Problem, mit dem ich konfrontiert war:
$ 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)
Ich habe den Vorschlag der akzeptierten Antwort ausprobiert, aber Folgendes erhalten:
$ git push origin :fix
error: unable to delete 'fix': remote ref does not exist
error: failed to push some refs to <repo URL>
Der Schiedsrichter existierte also nicht einmal origin- er hing eindeutig nur irgendwo auf meinem lokalen Repo herum. Also rannte ich $ git remote show me, was produzierte:
Remote branches:
...
refs/remotes/origin/fix stale (use 'git remote prune' to remove)
...
Was dann die Lösung klar machte:
$ git remote prune origin
Pruning origin
URL: <redacted>
* [pruned] origin/fix
Damit verschwand das Problem:
$ 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