首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Git推送错误:无法创建‘.Git/refs/remotes/jr/ exists . push’:文件存在

Git推送错误:无法创建‘.Git/refs/remotes/jr/ exists . push’:文件存在
EN

Stack Overflow用户
提问于 2018-09-14 01:34:32
回答 1查看 3K关注 0票数 2

这不是复制品。我看过this stack overflow postthis post,并尝试了他们的解决方案,但没有奏效。

我正在使用Ubuntu16.04,并试图将一个项目推送给Github。

当我跑步时:

git push jr master

我知道这个错误:

代码语言:javascript
复制
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

我运行了以下命令:

代码语言:javascript
复制
rm -f .git/refs/heads/master.lock
rm -f .git/index.lock

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-14 02:00:48

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

代码语言:javascript
复制
sudo chown -R john /home/john/Desktop/john-rykken-V2/.git

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

编辑:

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52323860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档