Git Issue

git pull error: cannot lock refs | cannot lock ref refs is at but expected | git error

Advertisement

After cloning from remote git repository I made some changes, committed and tried to push or

Tried to pull latest code from remote repository but getting below error?

Errors with like error: cannot lock ref

error: cannot lock existing info/refs
fatal: git-http-push failed

This case regards already existing repository.

I’m using Windows. The detailed error was:

error: cannot lock existing info/refs
fatal: git-http-push failed
 
Advertisement

Solution

git pull error: cannot lock refs, cannot lock ref refs is at but expected, how to fix?

Just run this command

git remote prune origin

This will do is remove references to remote branches in the folder .git/refs/remotes/origin. So this will not affect your local branches and it will not change anything remotely, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly.

“git pull error: cannot lock refs, cannot lock ref refs is at but expected” solution is very simple for this git error. Just run this command:

git remote prune origin

What this command will do?
This will do is remove references to remote branches in the folder .git/refs/remotes/origin. So this will not affect your local branches and it will not change anything remotely, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly.

This should ideally work, if not working, checkout repository again.

  • If this doesn’t work, you can try deleting that branch from local and checkout again.

Also Read: Microservices Interview Questions
could not get lock /var/lib/dpkg/lock | resource temporarily unavailable

Advertisement

Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen − seven =

Share on Social Media