This answer doesn't solve the OP's problem, but solves a similar one.
I had a similar problem (I got error: cannot lock ref ... is at ... but expected ...
), but it was because there were two branches in the repo with the same name, but with different case. Maybe this answer could help people that get here, I wasn't able to find an answer elsewhere.
I deleted one of the branches, and then deleted its corresponding reference from: .git/ref/.../branch_name
, then git pulled. This happens due to me working on a case-insensitive file system, while the two branches were pushed on a case-sensitive file system.
For example, the two branches are BRANCH1
and branch1
, and they are both under origin
remote. First, delete one of the branches, for example BRANCH1
. Then remove its ref:
rm .git/refs/remotes/origin/BRANCH1
Then git pull
, and it should be fine.