I am new to git
and was trying to commit, but I got stuck in what looked like vi
which I\'m not familiar with. I managed to get out of it, but I think
mine was solved with both answers from Platinum Azure then Suhail Taj
git commit -am "Changed this, that, and the other thing"
Then
$ rm -rf .git/index.lock
Note the message will improve and be more explicit with git 2.9 (June 2016), in order to invite you to consider all the causes before removing that lock yourself.
See commit aed7480, commit 3030c29 (01 Mar 2016) by Matthieu Moy (moy).
Helped-by: Moritz Neeb (zormit).
(Merged by Junio C Hamano -- gitster -- in commit 3b8c4b7, 03 Apr 2016)
lockfile: improve error message when lockfile exists
A common mistake leading a user to see this message is to launch "
git commit
", let the editor open (and forget about it), and try again to commit.The previous message was going too quickly to "a git process crashed" and to the advice "remove the file manually".
This patch modifies the message in two ways:
- first, it considers that "another process is running" is the norm, not the exception,
- and it explicitly hints the user to look at text editors.
The message is 2 lines longer, but this is not a problem since experienced users do not see the message often.
Removing index.lock file manually from .git directory worked.
or
From command line:
$ rm -rf .git/index.lock
Note: Make sure that only one index file exist on .git directory
Assuming you're not doing anything with git at the moment (i.e., not doing a push or pull or running a git script in the repository, for any reason), you could just remove the lock file manually and try again.
Also, git expects a "commit message" describing your changes. Assuming you don't want an editor to open, you can provide an inline message using the -m
option:
git commit -am "Changed this, that, and the other thing"