Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create '/git/index.lock': File exists - but it doesn't

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.

like image 532
Manza Avatar asked Apr 12 '16 08:04

Manza


People also ask

What is index lock file in Git?

When you perform a Git command that edits the index, Git creates a new index. lock file, writes the changes, and then renames the file. The index. lock file indicates to other Git processes that the repository is locked for editing.

How do I lock a file in a git repository?

lock file manually via this command or a similar command on your operating system: rm . git/index. lock .

What is Unlock index in Git GUI?

What does "Unlock Index" do in the Git Gui? It removes the ". git/index. lock" file so that you can run other git commands before continuing. The Git GUI will create this file when it starts a Git command so that no other git processes will interfere and corrupt your local repository.

Why can't I Create/Path/My_Proj/Git/index lock?

fatal: Unable to create '/path/my_proj/.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.

Is it possible to create index lock file in Git folder?

It's not able to create index.lock file in .git folder. I also give full permission to .git folder and also try to remove direct index.lock file from .git directory but same error like as bellow.

Why is Git add not working?

git add . fatal: Unable to create '/path/my_proj/.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.

What is Git add fatal error in Git?

git add . fatal: Unable to create '/path/my_proj/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.


3 Answers

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.

like image 105
bjblock Avatar answered Oct 08 '22 22:10

bjblock


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.

like image 3
hmofrad Avatar answered Oct 08 '22 21:10

hmofrad


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.

like image 1
Liquid_IQ Avatar answered Oct 08 '22 22:10

Liquid_IQ