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

其他回答

需要删除索引。锁文件。

在Linux中

cd .git
rm -f index.lock

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

cd .git
del index.lock

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

用这个:

rm -Force ./.git/index.lock

我已经更改了我的目录权限,所以我知道它可能与权限相关。在我的情况下,我删除了不需要的(_www)用户,然后通过应用更改所有内容应用读/写权限给每个人。这是Mac上的

我也有这个问题,而且我发现这真的是一个许可问题。所以我这样做:

sudo chown -R : .git #change group
sudo chmod -R 775 .git #change permission

那么一切都是伟大的,gaa是成功。

然后我用gp,得到另一个几乎相同的错误

sudo chown -R "${USER:-$(id -un)}" . #use this can fix the problem