Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot pull, git cannot resolve reference ORIG_HEAD

Tags:

git

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.

like image 394
vvondra Avatar asked May 13 '12 08:05

vvondra


People also ask

How do I fix broken references in git?

Solution. Unsure the root cause of the "reference broken". To fix it, delete this file . git/refs/remotes/origin/master , and git fetch to retrieve it back.

What is Orig_head in git?

ORIG_HEAD is created by commands that move your HEAD in a drastic way, to record the position of the HEAD before their operation, so that you can easily change the tip of the branch back to the state before you ran them. MERGE_HEAD records the commit(s) which you are merging into your branch when you run git merge.

What git fetch does?

Git fetch summary In review, git fetch is a primary command used to download contents from a remote repository. git fetch is used in conjunction with git remote , git branch , git checkout , and git reset to update a local repository to the state of a remote.


1 Answers

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.

like image 86
Brian Minton Avatar answered Oct 14 '22 04:10

Brian Minton