Git Error: (unable to update local ref)

Gabriel A. Quiles-Pérez
1 min readMar 20, 2020

--

I’ve been using git for at least 5 years now. Today I got an error that I’ve never seen before. I was trying to push my changes to github and it failed with the following error:

! 123..456 myBranch -> origin/myBranch (unable to update local ref)

After a quick search in google I found the solution. It seems that this error is caused due to a loose commit. Somehow I ended up with a commit not being referenced by any branch?

The solution to this error is to clean and optimize git files. You can accomplish tha,t by running

git gc --prune=now

This command will get rid of loose commits and repackage all referenced commits from now backwards.

Ref:

https://stackoverflow.com/questions/10068640/git-error-on-git-pull-unable-to-update-local-ref

--

--