4thSpace
4thSpace

Reputation: 44352

How to resolve Git permission denied /.git/index.lock

I'm logged in as an admin user but cannot checkin files into a git repository. I keep getting:

fatal: Unable to create '.../.git/index.lock': Permission denied

I did try ls -la .git/index.lock but get a not exist error.

I haven't found anything to fix this. Does anyone have some suggestions?

Upvotes: 1

Views: 7794

Answers (4)

Piumaster
Piumaster

Reputation: 1

I tried to change the permissions; however, every time the action was executed, the permissions were changed. The only way I found was to delete the index file.

rm -rf .git/index

Upvotes: 0

M Karimi
M Karimi

Reputation: 3593

Try deleting index.lock file in your .git directory.

Upvotes: 0

Anubhav
Anubhav

Reputation: 171

The quick way is to delete the file.

cd <repo-dir>
rm -rf .git/index.lock

You may want to setup the permissions properly.

sudo chown -R <owner>:<group> .git # set group
sudo chmod -R 775 .git # access rights

From internet search

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.

Upvotes: 2

4thSpace
4thSpace

Reputation: 44352

After running several command lines with no luck, I deleted the index.lock file. Then ran more commands with no luck. Then I deleted the local repository and downloaded again. This time everything is working and I can check in files.

Upvotes: 1

Related Questions