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

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


当前回答

错误代码将为您提供文件的完整路径。复制该路径并删除该文件。

例如,

fatal: Unable to create '/Users/username/Development/project/.git/index.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.
rm -rf fullPathOftheFile
rm -rf /Users/username/Development/project/.git/index.lock

其他回答

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

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

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

rm -f .git/index.lock

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

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

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

我刚开始学习Python,就遇到了这个问题。在通读并尝试了针对这个问题提供的所有可能的解决方案后,没有一个对我有效。我使用的是Windows 10 64位系统。Visual Studio代码文本编辑器。

所以我简单地复制并粘贴venv文件夹到.git文件夹中,就这样了。

我在使用Sourcetree时也遇到了同样的问题。但是没有任何索引。锁定文件在我的主机上。我找到了打包的裁判。锁定文件,删除后问题就解决了。