当我试图移动我的项目树到git repo时,我仍然得到这个错误消息。

我检查了我的目录与这个项目的权限,这些设置为777。在终端的my_project目录下设置:

git init

然后如果我尝试

转到添加 。

or

Git commit -m "first upload"

我就会得到错误

fatal: Unable to create '/path/my_proj/.git/index.lock': File exists.

If no other git process is currently running, this probably means a git process crashed in this repository earlier. 
Make sure no other git process is running and remove the file manually to continue.

我也尝试创建一个新的回购,并在那里提交它,但不幸的是,仍然是相同的错误消息。

问题的原因是什么?


当前回答

对我来说

rm -r .git-credentials.lock 

其他回答

我认为有一个比删除文件更好的解决方案(天知道用sudo删除/创建文件时会发生什么):

git gc

只需转到D:/project/androidgc/。Git /此目录并删除索引。这个锁对我有用。

不要使用Atom platform - Atom -ide-terminal Plugin来做这件事。 直接使用您的发行版的终端。

我在重基/压缩提交时一直得到这个错误,不知道为什么,因为我之前已经做过几次了。

不管我删除索引多少次。锁定文件,每次都会失败。

事实证明,这是因为我正在使用ATOM EDITOR终端插件。当我使用Ubuntu自带的终端时,它就像一个魅力。

所有的删除命令都没有为我工作,我所做的是使用git提供的路径导航,然后手动删除它。

需要删除索引。锁文件。

在Linux中

cd .git
rm -f index.lock

在Windows(10)中,在repo目录下的命令提示符中执行此操作:

cd .git
del index.lock