无法创建'/git/index.lock':文件存在-但不存在

Man*_*nza 5 windows git git-rebase sourcetree

尝试使用源代码树进行交互式基准调整时,出现此消息。

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.
Run Code Online (Sandbox Code Playgroud)

致命:无法创建'X:/sources/project/.git/index.lock':文件存在。

问题是X:/sources/project/.git/index.lock不存在

SO上的所有其他解决方案都不适合我,因为它们都说要删除此文件。

小智 10

我在 Mac 上遇到了基本相同的问题。运行时git rebase -i master,我收到一个错误:

致命:无法创建“路径/到/文件/.git/index.lock”:文件存在。

index.lock文件并不在我的存在的.git /目录。但是有一个索引文件(没有文件类型扩展名)。所以我中止了rebase。

经过大量的搜索,我终于决定只创建文件: touch .git/index.lock

我再次尝试变基,但这并没有解决问题(这次文件确实存在)。所以我删除了它: rm .git/index.lock

这就是诀窍。这次 rebase 有冲突(这很奇怪,因为我之前中止了 rebase),但我只是解决了每个冲突,然后让 rebase 继续: git rebase --continue

我希望这可以帮助其他遇到类似情况的人。


Dav*_*zer 0

好吧,这确实很奇怪,但对我来说,以下方法有效:

  • 从 Windows 资源管理器创建文件 .git/index.lock
  • 再次删除文件(来自git bash,我不知道这是否重要)

然后,我正在执行的命令(git rebase --continue在我的例子中)成功了。但我不知道为什么这个程序有效。这应该没有什么区别......