Git 推送错误:无法创建“.git/refs/remotes/jr/master.lock":文件存在 [英] Git push ERROR: Unable to create '.git/refs/remotes/jr/master.lock': File exists

查看:58
本文介绍了Git 推送错误:无法创建“.git/refs/remotes/jr/master.lock":文件存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这不是重复的.我看过 这个堆栈溢出帖子这篇文章 并尝试了他们的解决方案,但没有奏效.

This isn't a duplicate. I have looked at this stack overflow post and this post and tried their solutions, which didn't work.

我正在使用 Ubuntu 16.04 并尝试将项目推送到 Github.

I'm using Ubuntu 16.04 and trying to push a project to Github.

当我跑步时:

git push jr master

我收到此错误:

error: update_ref failed for ref 'refs/remotes/jr/master': cannot lock
ref 'refs/remotes/jr/master': Unable to create 
'/home/john/Desktop/john-rykken-V2/.git/refs/remotes/jr/master.lock': 
File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
Everything up-to-date

我已经运行了以下命令:

I have run the following commands:

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

都没有用.我还重新启动了我的机器并运行 ps -a |grep git,但没有找到任何正在运行的进程.最后,当我进入我的项目目录并手动搜索master.lock时,我找不到它.

Neither worked. I've also rebooted my machine and run ps -a | grep git, but didn't find any running processes. Finally, when I go into my project directory and manually search for master.lock, I can't find it.

建议?我的下一步是重新克隆存储库.

Suggestions? My next step is re-cloning the repository.

推荐答案

您可能使用 sudo 运行了 git 命令,这导致 .git 存储库中的某些文件归 root 所有.尝试运行此命令将存储库中所有文件的所有权更改为您的用户:

You've probably ran a git command with sudo, which has caused some of the files in your .git repository to be owned by root. Try running this command to change the ownership of all the files in your repository to your user:

sudo chown -R john /home/john/Desktop/john-rykken-V2/.git

我在这里假设您正在尝试与用户 john 一起运行 git.否则,将其更改为正确的用户.

I'm assuming here that you are trying to run git with user john. Otherwise, change that to the correct user.

事实证明,必须删除错误消息中的文件:rm -f .git/refs/remotes/jr/master.lock

As it turns out, the file on the error message had to be deleted: rm -f .git/refs/remotes/jr/master.lock

这篇关于Git 推送错误:无法创建“.git/refs/remotes/jr/master.lock":文件存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆