协慌网

登录 贡献 社区

此存储库中似乎正在运行另一个 git 进程

我正在尝试学习如何使用 Git,并使用 HTML,CSS 和 Javascript 文件创建了一个小项目。我从基本为空的项目中创建了一个分支,然后对代码进行了一些更改。我尝试分阶段进行更改,但收到以下错误消息:

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 bash,因为我不知道如何摆脱我的迷路。

有什么办法可以解决此问题,还是应该只启动一个新的存储库?

答案

尝试删除.git目录中的index.lock文件。

rm -f .git/index.lock

git命令时,通常会发生此类问题。也许一个来自命令提示符,另一个来自 IDE。

在应用程序的根目录中使用以下命令。这将删除 index.lock 文件并释放活动锁。

rm .git/index.lock

删除我的提交消息对我有用。

rm .git/COMMIT_EDITMSG

然后说。

致命:无法锁定参考'HEAD':无法创建 '.git / refs / heads / [您的分支名称] .lock':文件存在。

请注意,您的分支名称可能与我的不同。您可以通过执行以下操作删除此锁定文件:

rm .git/refs/heads/[your-branch-name].lock

希望这对某人有帮助。