Last Updated: March 20, 2018
·
6.834K
· kanshuYokoo

git: index.lock': File exists. can not commit or whatever

Quick Remedy is
- Quit the editor or IDE yo are using.

still not fixed, then delete ".git/index.lock"

The error was occurred when I was trying to merge upstream/master. I have got the following message.
" .git/index.lock and it should be safe to just remove it if you have no other git processes running. Make sure a git-svn command isn't hanging "
This might be appear any git command whether merging or committing.
There is the solution to fix problem on the internet, which is to delete your '.git/index.lock' but I have a bad feeling about that.
Then What I did actually was to quite Visual Studio Code, which i used to edit my source. then the problem was fixed.
If you have the similar issue, I suggest at first try to quite the editor, IDE, for example Xcode, unity. then try to command git again. I hope it works.
If not, maybe you have to delete '.git/index.lock' but be careful enough not to delete index.
Some people mentioned that not only .git/index.lock you need to delete .git/.*.swp. which mean any files which has .swp extention.
I case you are not familiar with terminal command, you have to

$ls -a .git/

because the file start with . is hidden file and for example you can not see .git/.COMMIT_EDITMSG.swp, on finder.
to delete these file,

$rm .git/index.lock

$rm .git/.COMMIT_EDITMSG.swp