Git Error on Git Pull (Unable to Update Local Ref)
I Only Have Branch Master and Im Getting This Error Every Time I Try to "Git Pull": Error: Couldn't Set Refs/Remotes/Origin/Master from...
I only have branch master and im getting this error every time i try to "git pull":
error: Couldn't set refs/remotes/origin/master
From /var/lib/git/xxx/project
! a0f80ea..49177a3 master -> origin/master (unable to update local ref)
and when i do "git pull origin master" i get:
error: Couldn't set ORIG_HEAD
fatal: Cannot update the ref 'ORIG_HEAD'.
i have been searching but cant find why
27 Answers
My team and I ran into this error, unable to update local ref, when doing a pull in SourceTree.
Update 2020: Per @Edward Yang's answer below, @bryan's comment on this answer, and this question/answer you may need to run both
git gc --prune=nowandgit remote prune origin. Running only the former has always worked for me but based on ppl's responses I think both are necessary to address different causes of the error.
We used:
git gc --prune=now
This removes any duplicate reference objects which should fix the issue.
Here are a few links where you can learn more about git references and pruning :
I solved as below:
git remote prune origin
with gitbach line commande, use git update-ref to update reference of your local branch:
$ git update-ref -d refs/remotes/origin/[locked branch name]
then pull using $ git pull
[locked branch name] is the name of the branch that the error is happening because of mismatch of commit Ids.
Try to use this command in your git repository root folder:
rm .git/logs/refs/remotes/origin/master
rm .git/refs/remotes/origin/master
It works to me!
Problem
Windows users can often have this problem
git pull
gives the error: error: cannot lock ref unable to update local ref