我跟踪了许多像project/.git/index.lock': File exists.这样的链接,但是没有一个是为我工作的。当我尝试将两个项目提交到GIT存储库时,我已经完成了以下两个项目
/d/Local Development/Shiva/shiva-tutorials/springboot-heroku-docker (master)
$ ls -ltra
total 9
-rw-r--r-- 1 541344 1049089 664 Aug 30 10:46 pom.xml
drwxr-xr-x 1 541344 1049089 0 Jan 2 15:12 ../
drwxr-xr-x 1 541344 1049089 0 Jan 2 15:12 ./
drwxr-xr-x 1 541344 1049089 0 Jan 2 15:14 springboot-heroku-demo/
drwxr-xr-x 1 541344 1049089 0 Jan 2 15:14 springboot-mysql-docker-demo/我开始看到下面的错误,不知道哪里出了问题?事实上,我没有看到任何. .git/文件夹被删除。请引导我。

命令行错误:
/D/本地Development/Shiva/shiva-tutorials/springboot-heroku-docker (主版)
$ git add *
fatal: Unable to create 'D:/Local Development/Shiva/shiva-tutorials/.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.发布于 2017-01-02 12:10:24
从定义上看,以点(.)开头的文件隐藏在linux文件系统中。因此,您没有看到.git和ls -ltra,因为您没有列出隐藏的文件。使用ls -ltrah,您将看到.git文件夹。但是,不要删除.git文件夹,而只删除其中的index.lock文件。当这个问题发生在我身上时,我通常会在Git进程有锁的时候杀死它,并做一些工作,这将使文件处于位置并锁定回购程序。
发布于 2020-07-19 09:42:37
你可以用它
rm -f ./.git/index.lock
发布于 2022-09-12 00:56:39
运行:
git rev-parse --git-dir然后你会得到.git
然后跑:
rm ./.git/index.lock 若要删除锁定文件,请执行以下操作。
https://stackoverflow.com/questions/41424620
复制相似问题