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

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


当前回答

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

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

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

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

其他回答

如果您是Windows用户,将会出现“‘rm’不能被识别为内部或外部命令”的错误。这是因为rm是一个Linux命令。所以在Windows中,你可以使用下面的方法来删除索引。锁定文件在。git文件夹中:

del -f .git/index.lock

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

例如,

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

在应用程序的根目录中使用以下命令。这将删除索引。锁定文件并释放活动锁。

rm .git/index.lock

在这里输入图像描述 如果这是你的情况,那么很容易解决。该问题将通过以下步骤解决。

在您工作的文件夹中输入Git的隐藏文件夹。 删除”指数。锁”文件 使用“git status”命令查看git状态 如果你的文件没有提交,你必须使用“git add——all”命令提交你的文件 再次检查git状态,执行文件并提交

做得好!我希望你已经解决了这个问题。

我的Mac很慢,所以我运行了2次git提交:一次执行,第二次被第一次阻塞。 我尝试了rm -f .git/index.lock rm . /文献/头/ your-branch-name .lock < repo>/.git/index.lock的路径 <路径到你的回购>/。Git /modules/<你的子模块>/index.lock的路径

@Ankush:

查找| grep '\.lock$' Rm -f ./.git/index。这是有用的检查-没有.lock文件潜伏

我做了@Chole所做的-检查出我的IDE退出,并再次查看git状态。然后运行$git添加。$git commit -m'msg' $git push

清除了正在运行命令的2个终端,解决了该问题。希望这能帮助到一些人-诊断很好,所以谢谢大家,非常有帮助。

一个缓慢的Mac之前已经导致了这个问题-所以现在我只是等待一段时间,然后运行第二次提交,与第一次冲突。