WSL2git无法创建index.lock并且无法取消链接index.lock

问题描述

问题

首先,只要我执行git addgit commit,就会发生这种情况。

fatal: Unable to create '/mnt/d/xxx/.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.

然后,我删除index.lock文件,并发生了此错误

warning: unable to unlink '/mnt/d/xxx/.git/index.lock': Permission denied
fatal: unable to write new index file

index.lock更改为权限755(我也确保自己拥有此文件)后,错误消息又回到了一个fatal: Unable to create '/mnt/d/xxx/.git/index.lock': File exists.

基本上,这会导致错误循环,并且无法进行任何暂存和提交。甚至在删除index.lock文件后重新启动计算机也无法解决问题。

  • 但是,我找到了一种解决方法方法是切换到cmd提示符并执行等效的git add / git commit(但我希望能够在WSL2中工作)。

设置

  • git项目是使用WSL创建的,但是我确实将其放置在Windows目录中。 (它工作了好几天,今天又以某种方式发生了此问题)
  • 文件夹的所有权已正确设置为当前的WSL用户
  • 除当前会话外,没有其他与git关联的进程正在运行。 (我使用ps -fe在WSL中进行了检查,并在Powershell get-process中进行了检查)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)