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

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


当前回答

删除索引。锁定在这里:

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

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

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

其他回答

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

那么一切都好了!

我正在使用PyCharm IDE。

rm -f .git/index.lock

上面的命令不起作用。不如试试下面的方法:

rm -force .git/index.lock

PyCharm IDE终端截图

PyCharm IDE终端截图

这也可能来自其他使用git的应用程序或插件 例如源树。在我的情况下,似乎有一些进程卡住了源树关于git。删除索引。锁档对我没用。我想删除项目目录下。git文件夹中的sourcetreconfig,它工作了。

rm -rf .git/index.lock
rm -rf .git/sourcetreeconfig

它可能正在发生,你的分支已损坏,创建新的分支 Git分支#检查分支。我已经创建了一个新的分支并在工作。

branch -b "main"
git checkout -b "main"  #main is new branch
git add .
git commit -m "all files"
git remote add origin #**YOUR REPO**  https://github.com/tarun-techmarbles/wp-dump-sql-git-push.git
git push origin main  #push with new branch 

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