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

ぐ巨炮叔叔 提交于 2019-12-19 05:08:57

问题


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?


回答1:


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



回答2:


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.




回答3:


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.




回答4:


I just used 'sudo' before my commit and it worked. I.e. "sudo git commit -am'commit message'"



来源:https://stackoverflow.com/questions/8500089/fatal-unable-to-create-refs-heads-master-lock-file-exists-fatal-getting-t

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!