Search code examples
githeroku

Unable to create 'D:/Local Development/Shiva/shiva-tutorials/.git/index.lock': File exists


I followed many links like Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists. but none of them gets worked for me. I've below two projects, when I tried to commit them into the GIT repository

 /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/

I started seeing the below errors, not sure whats going wrong? The fact that I dont see any .git/ folder to be delete. Please guide me.

enter image description here

The command line errors:

/d/Local Development/Shiva/shiva-tutorials/springboot-heroku-docker (master)

$ 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.

Solution

  • Files starting with a dot (.) are by definition hidden on a linux filesystem. Because of that you do not see .git with ls -ltra as you do not list hidden files. Use ls -ltrah and you will see the .git folder. But do not delete the .git folder, but only the index.lock file within it. When this problem happens to me, I usually killed a Git process while it had the lock and was doing some work which will leave the file in place and the repo locked.