git index.lock File exists when I try to commit, but cannot delete the file
This may be an old reply but I'm hoping this is more useful on next who need this solution.
On linux/unix/gitbash/cygwin, try
rm -f .git/index.lock
On Windows Command Prompt, try:
del .git\index.lock
For Windows:
- From a powershell console opened as admin, try
> rm -Force ./.git/index.lock
- If that does not work, you must kill all git.exe processes
> taskkill /F /IM git.exe SUCCESS: The process "git.exe" with PID 20448 has been terminated. SUCCESS: The process "git.exe" with PID 11312 has been terminated. SUCCESS: The process "git.exe" with PID 23868 has been terminated. SUCCESS: The process "git.exe" with PID 27496 has been terminated. SUCCESS: The process "git.exe" with PID 33480 has been terminated. SUCCESS: The process "git.exe" with PID 28036 has been terminated. > rm -Force ./.git/index.lock
On a Windows platform running Visual Studio 2015 RC (v4.6.00057) in combination with SourceTree (v1.6.14.0) will give this error as well.
Solution: Assuming you want to use source tree as source code manager, simply disable the source control provider inside Visual Studio like this:
- Go to: Tools > Options > Source Control
- Select Current source control plug-in as: None
- check if the git still running (ps -ef | grep git)
- if not, remove the locked file
- if yes, kill the git process at first.