Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove .git/index.lock': Permission denied

Tags:

git

macos

I'm completely stuck as to why my git has completely locked me out. I have a laptop that I use at work and when I'm home. For both accounts I use git extensively and both are located in different paths. Today I came into work and I can't do anything, all I see is:

/Applications/MAMP/htdocs/my_site/.git/index.lock': Permission denied 

For all I care the branch I'm on can be deleted. I've tried removing the branch, checking out any other branch, removing the index.lock file (as suggested by other users on sites). I only have the terminal window open, no other possible programs using git (as far as I know and nothing noticeable in the activity window). I have rebooted the computer straight into my work account and still no luck. How can I remove this lock?

like image 518
user1760561 Avatar asked Jan 02 '13 18:01

user1760561


People also ask

Can I delete Git index lock?

If you don't have any Git processes running, you can delete the index. lock file and try the Git operation again.

What is index lock 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.


Video Answer


2 Answers

I had the exact same problem wanting to commit my changes to git, and solved it this way:

  • I needed to change the group of my .git folder and its contents:

    sudo chown -R <owner>:<group> .git

  • needed to change the permission of this folder:

    sudo chmod -R 775 .git

like image 153
Mahshid Zeinaly Avatar answered Sep 24 '22 07:09

Mahshid Zeinaly


Check which user owns the git lock:

ls -la /Applications/MAMP/htdocs/my_site/.git/index.lock 

Then you can use sudo to remove it.

like image 41
Jure C. Avatar answered Sep 26 '22 07:09

Jure C.