当我试图移动我的项目树到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.

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

问题的原因是什么?


当前回答

对我来说,解决办法是等5分钟。显然我之前的手术还在进行,只是我不知道而已。我在用乌龟屎擦窗户。

其他回答

我也有同样的问题。我试着

rm -f ./.git/index.lock 

控制台给了我一个错误信息。然后,我尝试了

rm --force ./.git/index.lock

这很有效。

好运! 这很有效

我们也可以直接终止git进程。我通过git的GUI应用程序收到相同的问题,出错了,git使一些工作无限。kill进程将冻结使用git的应用程序,只需重新启动它,一切都会好起来。

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

如果有人正在使用git svn,我有同样的问题,但不能删除文件,因为它不存在!在检查权限,触摸文件并删除它之后,我不记得还有其他什么,这是有效的:

签出主分支。 Git SVN rebase (master) 签出您正在处理的分支 Git SVN rebase

用这个:

rm -Force ./.git/index.lock