最新消息:20210917 已从crifan.com换到crifan.org

【已解决】git commit失败:fatal: Unable to create .git/index.lock’: File exists

Git crifan 700浏览 0评论
PyCharm中去调试一个Python的Flask项目,
后来不知道什么原因,导致了此处去git commit或git rm,都提示出错:
➜  xxxRobotDemoServer git:(master) ✗ git rm .idea/*
fatal: Unable to create '/Users/crifan/dev/dev_root/company/xxx/projects/robotDemo/server/xxxRobotDemoServer/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
git fatal: Unable to create .git/index.lock’: File exists
git 提交出现这个错误fatal: Unable to create ‘project_path/.git/index.lock’: File exists. – CSDN博客
Git – fatal: Unable to create ‘/path/my_project/.git/index.lock’: File exists – Stack Overflow
关于Git无法提交 index.lock的解决办法 – ConquerMobileApp – 博客园
➜  xxxRobotDemoServer git:(master) ✗ ls -lha ./.git/in*
-rw-r--r--  1 crifan  staff   8.9K  8 26 14:00 ./.git/index
-rw-r--r--  1 crifan  staff     0B  8 27 09:30 ./.git/index.lock

./.git/info:
total 8
drwxr-xr-x   3 crifan  staff    96B  5 18 15:48 .
drwxr-xr-x  14 crifan  staff   448B  8 27 09:30 ..
-rw-r--r--   1 crifan  staff   240B  5 18 15:48 exclude
➜  xxxRobotDemoServer git:(master) ✗ rm -f ./.git/index.lock
【总结】
此处git操作提示出错:
fatal: Unable to create .git/index.lock’: File exists
那就去删除掉那个lock文件即可:
rm -f ./.git/index.lock

转载请注明:在路上 » 【已解决】git commit失败:fatal: Unable to create .git/index.lock’: File exists

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
94 queries in 0.174 seconds, using 23.39MB memory