致命:无法创建“refs/heads/master.lock”:文件存在致命:- 在推送提交时出现此错误

发布于 2024-12-21 06:05:25 字数 318 浏览 1 评论 0原文

我在推送提交时收到以下错误,

$ 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

习ぎ惯性依靠 2024-12-28 06:05:25

您需要删除现有的 .lock 文件并尝试推送,

Linux

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

Windows

del .git\refs\heads\master.lock

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
恰似旧人归 2024-12-28 06:05:25

这是因为其他一些 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.

雪化雨蝶 2024-12-28 06:05:25

对于那些遇到此问题但无法使用接受的解决方案的人,因为该文件不存在可删除,这可能是权限问题。

这个问题应该会有所帮助。就我而言,我一直在不同的终端上使用 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.

唔猫 2024-12-28 06:05:25

正如此处发布的另一个答案所说,这可能是权限问题。就我而言,我必须在用户推送代码时登录服务器。然后我必须 cd 到用于推送代码的目录的父目录,最后我必须更改上述目录的所有者。

sudo chown -R usernameHere gitDirectoryName

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
旧伤慢歌 2024-12-28 06:05:25

我只是在提交之前使用了“sudo”并且它起作用了。即“sudo git commit -am'提交消息'”

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文