我试图学习如何使用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,因为我不知道如何摆脱我以某种方式得到的。

是否有办法解决这个问题,或者我应该开始一个新的存储库?


当前回答

这对我很管用。我得到了同样的错误。

删除HEAD。Windows 10上的“lock”文件。现在我可以在远程上提交和推送我的更改。

其他回答

删除索引。锁定在这里:

<path to your repo>/.git/index.lock

此外,如果存储库有子模块,请删除所有索引。锁定在这里:

<path to your repo>/.git/modules/<path to your submodule>/index.lock

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

rm .git/index.lock

我也遇到过同样的问题。问题是,我试图用一个大小为1.3 GB的XML文件(用作数据集)来推动我的代码。

解决方案是将该文件添加到.gitignore中,然后问题就解决了。

使用下面的命令,以防你遇到另一个git进程似乎正在这个存储库中运行。 由'git commit'打开的编辑器。请确保所有流程 终止,然后再试一次。如果它仍然失败,一个git进程 可能已经崩溃在这个存储库之前: 手动删除文件以继续。

Rm -f .git/index.lock

git重置 并且在reset命令后使用git status, git add,和git commit -a或者git commit -m "your message", git push origin master。

这种情况发生在我身上,虽然sourcetree一直告诉我锁文件存在,但没有这样的文件供我删除。所以我只是签出了另一个分支,然后返回到原来的分支,并注意到这个更改修复了问题。