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

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


当前回答

在我的例子中,只需运行命令:yarn add commitizen -D

那么一切都好了!

其他回答

尝试删除索引。锁定文件在你的。git目录或在你的一个工作树。git/worktrees/*/index。如果您在工作树中,请锁定。

rm -f .git/index.lock

这类问题通常发生在同时执行两个git命令时;可能一个来自命令提示符,一个来自IDE。

好的,我最终通过运行'git rm .git/index.lock'来让它工作…

这很奇怪,因为我以前这么做过几次都没有用,但是嘿,电脑,对吧?

如果你不幸使用了你的git或git remove从git总线,或者你不能提交你的代码和“git add .”并远程上传代码,那么请检查以下内容。

这个命令… 假设您的错误类型

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总线或Windows PowerShell 然后使用下面的命令 rm . / index.lock

对我来说,解决方案很简单,只需关闭IDE,然后签出。我的一个队友接受了我的PR,并通过TFS合并了代码。删除.lock文件不起作用。

虽然上面有一个替代方案,但这并没有解决我的问题。 在我的情况下,我删除了。/zshrc中的“git”插件并重新启动计算机,然后问题就消失了,我猜zsh插件已经做了一些与原始git命令冲突的事情。