Reputation: 2793
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?
Upvotes: 21
Views: 30864
Reputation: 11
Like another answer posted here says, it can be a permissions issue. In my case I had to login to the server as the user used to push the code. Then I had to cd to the parent directory of the directory used to push the code, and finally I had to change owner of the aforementioned directory.
sudo chown -R usernameHere gitDirectoryName
Upvotes: 0
Reputation: 106
For those who come to this page with this problem but can't use the accepted solution because the file doesn't exist to be deleted, it's probably a permissions issue.
This SO question should be helpful. In my case I had been working with both root and a normal user account on different terminals and must have done something as root and caused problems like is suggested in the linked answers. Solution was to fix permissions in my git directory back to the user.
Upvotes: 3
Reputation: 273
I just used 'sudo' before my commit and it worked. I.e. "sudo git commit -am'commit message'"
Upvotes: -4
Reputation: 27604
You need to remove existing .lock
file and try to push,
rm -f .git/refs/heads/master.lock
del .git\refs\heads\master.lock
Upvotes: 24
Reputation: 301037
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.
Upvotes: 7