致命:无法创建“refs/heads/master.lock”:文件存在致命:- 在推送提交时出现此错误
我在推送提交时收到以下错误,
$ git push origin master
fatal: unable to create 'refs/heads/master.lock': File exists fatal:
The remote end hung up unexpectedly
我想从本地计算机中删除锁定文件 (refs/heads/master.lock
)。但这个文件不可用。我认为这个文件在 git 服务器中。
这个问题的根源是什么?如果我从服务器中删除该文件,如果该文件存在,是否可以解决问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您需要删除现有的
.lock
文件并尝试推送,Linux
Windows
You need to remove existing
.lock
file and try to push,Linux
Windows
这是因为其他一些 git 操作可能在中间已经终止(甚至仍然在罕见的情况下运行)并留下了锁定文件。一旦看到服务器上没有运行 git 相关进程,为了安全起见,您可以删除该文件并再次尝试推送。
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.
对于那些遇到此问题但无法使用接受的解决方案的人,因为该文件不存在可删除,这可能是权限问题。
这个问题应该会有所帮助。就我而言,我一直在不同的终端上使用 root 帐户和普通用户帐户,并且必须以 root 身份执行某些操作并导致出现链接答案中建议的问题。解决方案是将我的 git 目录中的权限修复回用户。
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.
正如此处发布的另一个答案所说,这可能是权限问题。就我而言,我必须在用户推送代码时登录服务器。然后我必须 cd 到用于推送代码的目录的父目录,最后我必须更改上述目录的所有者。
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”并且它起作用了。即“sudo git commit -am'提交消息'”
I just used 'sudo' before my commit and it worked. I.e. "sudo git commit -am'commit message'"