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

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


当前回答

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

rm .git/COMMIT_EDITMSG

它接着说。

fatal:无法锁定ref 'HEAD':无法创建'.git/refs/heads/[your-branch-name]。lock `:文件已存在。

请注意,您的分支名称可能与我的不同。您可以通过执行;

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

其他回答

它类似于上述方法,但在我的情况下,我有几个这样的方法

.git/refs/heads/<branch_name>.lock

通过这种方法,可以一次性去除

find -name "*.lock" -exec xargs rm {} \;

使用下面的命令,以防你遇到另一个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。

首先,运行

rm -f .git/index.lock

然后运行

git reset --hard

在命令提示符或Git Bash中。

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

rm -f .git/index.lock

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

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

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