index.lock 产生原因:

在你进行某些比较费时的 git 操作时自动生成,操作结束后自动删除,相当于一个锁定文件,目的在于防止对一个目录同时进行多个操作。

报错原因:

在 git 没有运行完的时候强制关闭,index.lock 没有被自动删除,下次提交就会产生此错误。

× git add found some errors. Please fix them and try committing again.

fatal: Unable to create 'xxx/.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.

解决办法:

手动删除 index.lock

我们看不见 .git 文件,直接用命令删除即可:

 rm -f .git/index.lock

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐