11

I'm getting this message when trying to rebase interactively using source tree.

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.

fatal: Unable to create 'X:/sources/project/.git/index.lock': File exists.

The problem is that X:/sources/project/.git/index.lock doesn't exist

All the other solutions on SO didn't work for me since they all say to remove this file.

Manza
  • 3,427
  • 4
  • 36
  • 57

7 Answers7

13

I'm on a Mac and ran into basically the same issue. When running git rebase -i master, I received an error:

fatal: Unable to create 'path/to/file/.git/index.lock': File exists.

The index.lock file didn't exist in my .git/ directory. But there was an index file (no filetype extension). So I aborted the rebase.

After a ton of searching, I finally decided to just create the file: touch .git/index.lock

I tried rebasing again, but that didn't fix the issue (this time the file really did exist). So I removed it: rm .git/index.lock

That did the trick. The rebase had conflicts this time (which was odd since I aborted the rebase previously), but I just addressed each conflict and then let the rebase continue: git rebase --continue

I hope this helps someone else who ends up in a similar situation.

bjblock
  • 131
  • 1
  • 6
3

Use rm -rf X:/sources/project/.git/index.lock to remove the lock and save yourself a headache. Also, the index.lock exists, however, the .git folder is hidden. So, use ls -la X:/sources/project/.git to see the content of a hidden folder.

hmofrad
  • 1,784
  • 2
  • 22
  • 28
  • 1
    There are cases in which index.lock simply doesn't exist, at least before one starts to rebase. It's not in the hidden .git folder. I'm now wrestling with that problem myself. – user697473 May 14 '21 at 14:28
1

I had the same issue using Github Desktop. I watched the .git directory and the index.LOCK file would appear and disappear. It never persisted for long, so was not there to delete. I investigated a little as other solutions online did not work for me and found that comparing permissions to folders that I was able to commit they had one difference: the .git folder that gave me the error had full control like the others, but it was inherited from its parent. I went to properties->security->advanced and removed then re-added the permissions without inheriting them from the parent. After that I was able to commit my changes without an error.

Liquid_IQ
  • 31
  • 2
0

OK, this is really strange, but for me, the following worked:

  • Create the file .git/index.lock from Windows explorer
  • Delete the file again (from git bash, I don't know if this is important)

Then, the command I was executing (git rebase --continue, in my case) succeeded. I have no idea why this procedure worked, though. This should not make any difference...

David Tanzer
  • 2,732
  • 18
  • 30
0

I disabled indexing of the .git folder and it helped to me to get rid of the message

double-beep
  • 5,031
  • 17
  • 33
  • 41
Jan
  • 1
0

@Manza: I came across the same issue. There is no index.lock file existing and still it throws an error related to file existence.

I created a patch of my changes and did a clone again. Now when I do a commit, it works all fine. I know this is not the right direction. But this is the go to when the index.lock doesn't get created and still we get this error.

Srikanth V
  • 229
  • 3
  • 5
0

for ios mac remove rm -rf from this location .git/modules/ios or can manual delete
Step — 1)-Open terminal . 2)-Open project file location. 3)-Rum command - defaults write com.apple.finder AppleShowAllFiles YES. Now u can see hidden file in Mac OS. 4)-Rum command - cd .git/modules/ios (In my case I am running React code). 5)-Now either open folder and delete index.lock or use “rm” command . 6)-Thats its - now try to commit and push .