【发布时间】:2020-10-18 13:23:00
【问题描述】:
我不小心停止了正在进行的 git 提交,后来当我尝试时
git commit -m"xyz"
我收到以下消息
fatal: cannot lock ref 'HEAD': Unable to create 'G:/folder/.git/HEAD.lock': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
我尝试按照这里给出的建议Git cannot lock ref 'HEAD': unable to resolve reference HEAD 并尝试过
rm -rf .git/refs/heads/
不幸的是,这没有帮助,当我尝试 git commit 时,我仍然收到上面发布的相同错误消息。
我也尝试了 git reset ,这也给出了上面显示的相同消息。
有关如何解决此问题的其他建议将非常有帮助。
【问题讨论】:
-
哇,
rm -rf .git/refs/heads/基本上破坏了您的存储库!如果没有,您要么没有任何提交,要么刚刚克隆了存储库,或者您刚刚完成了git gc。 -
在
.git/log下仍然可以找到引用的位置(名称和最后一次活动提交) -
@LeGEC:至少在我的机器上是带有 s 的
.git/logs。我很好奇,并尝试自己以这种方式创建一个 repo,而git reflog在这种状态下不适用于存储库,很高兴知道。 -
请定义“停止正在进行的提交”。怎么样?
-
@DaemonPainter 我做了一个 ctrl + C
标签: git