Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists

Tags:

git

I am still getting this error message, when I try to move my project tree on to git repo.

I checked the permissions of my directory with this project and these are set on 777. In terminal in the directory with my_project I set:

git init

and then if I try

git add .

or

git commit -m "first upload"

so I'll get the error

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. 

I tried also create a new repo and there to commit it, but unfortunately still the same error message.

What is the cause of problem?

like image 805
user984621 Avatar asked Oct 22 '11 16:10

user984621


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.


1 Answers

Try

rm -f ./.git/index.lock 

In your repository directory. The error message is rather explicit as to what causes it typically, so if you have no other git processes running (which is the normal case), go ahead and delete that file.

like image 182
Raphael R. Avatar answered Oct 21 '22 13:10

Raphael R.