提交git时,发生Unable to create ‘E:/project_namel/project_name/.git/index.lock‘: File exists.报错提示
·
发生场景:
项目场景:使用gitlab进行代码管理。在WebStorm提交代码中,提示错误信息。
问题描述
错误提示如下显示:

Unable to create 'E:/project_namel/project_name/.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.
它表明,无法创建 ‘E:/working/project_namel/project_name/.git/index.lock’,原因是该文件已经存在。
原因分析:
这个错误在于在同一个Git仓库中,另一个Git进程正在运行。因为’git commit’打开的编辑器时,有’git commit’或其他Git命令启动的编辑器或工具还在运行中,把进程给占了。想要解决这个问题,必须要确保所有与该仓库相关的Git进程都已
终止。
解决方案:
提示:在解决前预先备份代码,防止发生意外情况使数据丢失。
- 可以通过任务管理器(Windows)或活动监视器(Mac)来检查并结束任何相关的进程。
- 手动删除该文件


- 使用命令行删除该文件,如下:
rm -f .git/index.lock
结果展示:
删除index.lock文件后,重新提交,显示提交成功 !
以上。
更多推荐





所有评论(0)