Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal: unable to create 'refs/heads/master.lock': File exists fatal: - Getting this error while pushing the commits

Tags:

git

git-push

I am getting the following error while pushing the commit

$ git push origin master
fatal: unable to create 'refs/heads/master.lock': File exists fatal:
The remote end hung up unexpectedly

I thought of removing the lock file (refs/heads/master.lock) from my local machine. But this file is not available. I think this file is in git server.

What is the origin of this issue? If I remove this file from the server, will it solve the issue if the file exists?

like image 415
Jon Avatar asked Dec 14 '11 06:12

Jon


People also ask

What is Ref head in Git?

git/refs/ . In Git, a head is a ref that points to the tip (latest commit) of a branch. You can view your repository's heads in the path . git/refs/heads/ . In this path you will find one file for each branch, and the content in each file will be the commit ID of the tip (most recent commit) of that branch.


2 Answers

It is because some other git operation might have died ( or even still running in the rare ) in the middle and left a lock file. Once you see that no git related process is running on the server, just to be safe, you can delete the file and try to push again.

like image 33
manojlds Avatar answered Oct 07 '22 05:10

manojlds


You need to remove existing .lock file and try to push,

Linux

rm -f .git/refs/heads/master.lock

Windows

del .git\refs\heads\master.lock
like image 104
Jaykumar Patel Avatar answered Oct 07 '22 05:10

Jaykumar Patel