Git error on git pull (unable to update local ref)

Cover image

The Issue:

(unable to update local ref) OR

  error: Couldn't set ORIG_HEAD
  fatal: Cannot update the ref 'ORIG_HEAD'

Possible Causes:

  • Your clone/fork of the git repository is not updated with the remote branch updates.
  • The remote repository you are pulling from, is not tied to the local repository on your computer.

Solution:

  •  git gc --prune=now

    or

    git remote prune origin

    This would remove objects that are no longer referenced and duplicates.

  • If this doesn't fix your problem, then you might have to hard reset to the last commit.

      git reflog 
      git reset --hard <id> 
      git pull origin <branch> 

    git reflog: This would provide list of previous commits and their ids

Summary

That's all! You were expecting a longer read? Learn more about refs, git prune and git gc.

Git References

Git Prune

GC and Pruning

Stack Overflow