Cannot pull, git cannot resolve reference ORIG_HEAD
while pulling into my git repository from our central server, this error occured:
$ git pull origin master From http://aaa/repo * branch master -> FETCH_HEAD error: unable to resolve reference ORIG_HEAD: No such file or directory fatal: Cannot lock the ref 'ORIG_HEAD'.
I’ve tried git gc (with –prune=now) and looking for a similar error, unfortunately with no luck.
4 Solutions collect form web for “Cannot pull, git cannot resolve reference ORIG_HEAD”
I had this problem, and I solved it by removing the file .git/ORIG_HEAD then doing the pull again. The .git/ORIG_HEAD file was 0 bytes instead of the git reference it was supposed to contain, so I just got rid of it.
git remote prune origin mentioned in addition of the
git gc --prune=now in “
git pull fails “unalble to resolve reference” “unable to update local ref””.
If you have a
.git/rebase-merge, consider removing it (as in “
git rebase and deleted rebasing branches causing “Interactive rebase already started” error message”)
Check also the content of
.git/HEAD, as in this issue.
If this is a repo corruption of some kind (see “Git corrupt master branch”), try first to clone your repo again, and re-apply your current modifications on top of that repo (through
git format-patch if you need to)
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 they are both under
origin remote. First, delete one of the branches, for example
BRANCH1. Then remove its ref:
git pull, and it should be fine.
This file is created when you
git pull in a repository in order to not
git pull in the same repository more then ones at the time and it gets deleted when the process is finished. If the process dies or become a zombie, then the file is not removed and you have to check manually if the git process still exists. If the process doesn’t exists, then you have to delete the file and try to
git pull again.