【问题标题】:Git push ERROR: Unable to create '.git/refs/remotes/jr/master.lock': File existsGit推送错误:无法创建'.git/refs/remotes/jr/master.lock':文件存在
【发布时间】:2019-02-18 18:54:54
【问题描述】:

这不是重复的。我查看了this stack overflow postthis post 并尝试了他们的解决方案,但没有成功。

我正在使用 Ubuntu 16.04 并尝试将项目推送到 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

我已经运行了以下命令:

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

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

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

【问题讨论】:

    标签: git github ubuntu-16.04


    【解决方案1】:

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

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

    我在这里假设您正在尝试使用用户 john 运行 git。否则,请将其更改为正确的用户。

    编辑:

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

    【讨论】:

    • 你也试过rm -f .git/refs/remotes/jr/master.lock吗?
    • 成功了!如果您修改答案,我会接受。
    猜你喜欢
    • 2016-09-02
    • 2012-01-19
    • 2021-02-05
    • 2017-12-07
    • 1970-01-01
    • 2011-02-08
    • 1970-01-01
    • 2021-03-29
    • 2016-09-05
    相关资源
    最近更新 更多