当我做'git commit'时,我得到以下内容:

无法创建“project_path/.git/index”。lock `:文件已存在。

然而,当我执行ls project_path/.git/index。锁定,表示文件不存在。你觉得我该怎么做?我还注意到project_path/。git由root拥有,不确定这是否与我遇到的问题有关。

Git版本为1.7.5.4

编辑:看起来问题很可能是我正在运行的另一个进程,那就是向项目目录写入(我不知道)。我重新启动了我的电脑,然后我就没有问题了。


当前回答

关闭所有可能影响这个.git/index的窗口。锁文件 删除.git/index。锁文件。 打开命令行编辑器,cd到git文件的位置。

(如果创建文件只是简单地从cd到那个位置,那么问题出在编辑器上。关闭编辑器。不要在此任务中再次使用此编辑器。打开另一种编辑器- windows power shell或简单的cmd。现在你可以使用git命令继续)

其他回答

检查git是否仍在运行(ps -ef | grep git) 如果不存在,请移除该文件 如果是,请先关闭git进程。

我的解决方案是删除.index文件,并允许Git重新构建另一个。

对我来说,罪魁祸首是windows安全,它阻止了git.exe运行,你可以检查屏幕右下角的通知选项卡。

消息将如下所示

Virus and threat protection 
unauthorized changes blocked
controlled folder access blocked git.exe from running

通过删除你正在尝试的回购,我解决了这个问题 提交更改并从远程复制最新版本(如果 使用远程git服务器)。 如果是本地,则从目录中复制数据 并初始化一个新的git存储库。

获取错误:

Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
fatal: Unable to create '/home/user/project/.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/index。锁文件。

在我的情况下,吉特可乐正在运行!

它显然创建了。git/index。每隔一段时间就会锁一次,或者是由于我在命令行上所做的更改而导致的,在此期间我收到了这个错误-所以Git -cola显然会“干扰”Git的命令行运行(或一些Git CLI操作)。

这可以通过在命令行git rebase期间关闭git-cola来解决。