I ran into an issue today where I was unable to pull changes from a remote repo. The error message was:
❯ git pull
error: cannot lock ref 'refs/remotes/origin/broken-branch/test-new-feature': 'refs/remotes/origin/broken-branch' exists; cannot create 'refs/remotes/origin/broken-branch/test-new-feature'
From github.com:muh-org/main-repo
! [new branch] broken-branch/test-new-feature -> origin/broken-branch/test-new-feature (unable to update local ref)
The fix ended up being to delete the local ref for each branch that was causing the issue:
❯ git update-ref -d refs/remotes/origin/broken-branch
❯ git pull
From github.com:muh-org/main-repo
* [new branch] broken-branch/test-new-feature -> origin/broken-branch/test-new-feature
* [new branch] broken-branch/upgrade-dd-monitor-version -> origin/broken-branch/upgrade-dd-monitor-version
Updating a1a1a1a1a1..b2b2b2b2b2
Fast-forward
dir/file1 | 118 +++++++++++++++++++++++++-------------------------
dir/file2 | 118 +++++++++++++++++++++++++-------------------------
dir/file3 | 2 +-
dir/file4 | 4 --
dir/file5 | 4 --
...