我试图学习如何使用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 -f .git/index.lock

然后运行

git reset --hard

在命令提示符或Git Bash中。

其他回答

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

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

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

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

它可能正在发生,你的分支已损坏,创建新的分支 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 

首先,运行

rm -f .git/index.lock

然后运行

git reset --hard

在命令提示符或Git Bash中。

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

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

Rm -f .git/index。锁不起作用,因为我有一个无法删除的锁定文件。因此,索引。锁也被一些应用程序捕获了。

在Windows系统中,我下载了一个名为Lock Hunter的Unlocker替代品,并删除了这两个文件。Git抓住了他们。