git commit 提交时无法提交报错

git commit 提交时报错

fatal: Unable to create ‘e:/git/Android/XXXXXX/.git/index.lock’: File e
xists.

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文件夹里面的 index.lock删除即可。因为index.lock导致里面的
index无法运行所以删除index.lock就行

那index.lock有什么作用呢?
官方是这么说的:

在进行某些比较费时的git操作时自动生成,操作结束后自动删除,相当于一个锁定文件,目的在于防止对一个目录同时进行多个操作。有时强制关闭进行中的git操作,这个文件没有被自动删除,之后你就无法进行其他操作,必须手动删除。

通俗讲,就是我们在commit的时候,会自动生成一个index.lock文件,操作完成后,会自动删除。如果在commit过程中,产生了意外,比如手动退出了,电脑死机了,断网了等等,导致操作失败,没有自动删除index.lock文件,那么下次再commit的时候,系统不知道你的index.lock没删除,它会傻傻的再去创建index.lock文件,这时候,发现已经目录下已经有一个index.lock文件了,懵逼了,不知道咋处理了,所以抛错给你:

猜你喜欢

转载自blog.csdn.net/qq_47755376/article/details/110128372