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

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

问题的原因是什么?


当前回答

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

其他回答

如果你正在使用#intelliJ ide中的一个并接收到这个msg(我正在使用#webtorm),请注意这个问题可能会发生,因为隐藏了一个项目文件夹(在设置内部),这可以阻止git合并。

运行任务管理器,找到Git for windows进程并杀死它。 删除索引。锁定文件在。git文件夹下 这对我很管用!

对我来说

rm -r .git-credentials.lock 

Try

rm -f ./.git/index.lock

在存储库目录中。错误消息非常明确地说明了导致错误的原因,因此如果没有其他git进程正在运行(这是正常情况),请继续删除该文件。

对我来说有效的解决方案是关闭sublime文本,因为运行中的git进程是由编辑器启动的。