Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

fatal: Unable to create 'D:/Evi/Source/Git/.git/index.lock': File exists

Rainer Krachten October 30, 2015

Not every time, but quite often, I get this fatal error when trying to switch branches in my repository:

 

git -c diff.mnemonicprefix=false -c core.quotepath=false checkout <branch-name>

fatal: Unable to create 'D:/Evi/Source/Git/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

 

I think the problems started after I updated the Git-for-Windows version from 1.9.5 to 2.5.x and prevailed in 2.6.x. Restarting SourceTree solves the issue (temporarily). I noticed that the latest SourceTree version 1.6.22.0 still downloads the 1.9.5 preview version when I try switching to  Embedded Git.

So, is this an incompatibility issue of SourceTree with Git-for-Windows 2.x? A Fix really would be appreciated since having to restart SourceTree gets quite annoying. The issue exists on multiple machines in our company.

2 answers

0 votes
Phred January 12, 2016

I also get this error nearly every day.  If I watch the .git folder during an operation, I can see the index.lock briefly get created and then deleted.  It's a race condition in git and/or Sourcetree.

Also, it appears to be something that is actually caused by SourceTree because I don't get the problem if I use Git on the command line.

0 votes
Kay Zumbusch November 19, 2015

This error is really annoying and the error message is wrong. Any time I get this error message there is no index.lock file. If I open the Git Terminal from SourceTree and execute the same command the branch is switched correctly. As Rainer already mentioned the error is not permanent and can be worked around be restarting SourceTree.

My system git version is still at 1.9.5 and if I switch SourceTree to use this version changing branches works perfectly but then I can no longer access the Git bash terminal from SourceTree. I recently updated SourceTree to 1.6.23 and I did not encounter this problem in earlier versions.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events