当前位置:   article > 正文

使用Git 出现 Another git process seems to be running in this repository..._another git procc

another git procc

使用git 出现Another git process seems to be running in this repository…

用git的时候,用快捷键Ctrl + w 关闭一个网页的时候,不小心关到了 git,然后再次git 去git add 的时候,就报了如下的错误。


fatal: Unable to create ‘D:/LearnGit/.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.

大意如下: 在D盘LearnGit/.git里创建index.lock失败:文件已存在。git的进程已经在一个编辑器中被打开。请确保所有的进程都结束,然后再次尝试。如果仍然失败,可能是上个运行中的git崩溃,手动移除这个文件。

翻了下.git里的文件,里面有个index.lock文件。删除之后再继续git操作就没问题了。

后来了解了下,应该是windows对进程的管理有个上锁机制,正常情况下,会上锁,进程结束,然后解锁进程。但是由于我强制关闭了运行中的git,导致git崩溃,已经上锁的index.lock没有来得及解锁而仍然存在。当我再用git add的时候,git发现已经存在了index.lock这个文件,导致报错。

正常情况下 .git 是隐藏文件夹,需要手动的设置显示隐藏文件方可看到:

  • window下打开‘我的电脑’,在工具/文件夹选项/查看/里 勾选 显示隐藏的文件、文件夹或驱动器。然后进入文件夹删除index.lock文件。
  • 或者你可以这样:命令行里 cd 到 .git 这个目录下, 输入命令: rm index.lock 即可删除。
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号