Reputation: 1608
I am getting the following error while trying to commit to a local repository:
error: insufficient permission for adding an object to repository database .git/objects
I created another repository to compare the permissions of .git
and .git/objects
and everything works fine in the new repository, and the permissions are the same drwxr-xr-x
.
What might be causing this error?
Upvotes: 10
Views: 8713
Reputation: 101
cd <path-to-repo>
cd .git/objects
sudo chown -R <username>:<group> *
This worked for me with group staff
.
Upvotes: 4
Reputation: 1
I have faced the same issue. I thought my current working local repository got corrupted. So I have cloned the repository from remote again. Now I'm able to do commit and push from this new repository without any issues.
Note: If you want your old repo changes then use git stash and do git stash apply in new repo.
Upvotes: 0
Reputation: 4743
cd repository
chown -R user:group *
cd .git
chown -R user:group *
cd ..
the second chown is there because the first one didn't get into .git
Edit: If above does not help, try to run the chown commands as root.
Edit 2: replace 'user' and 'group' with your username and groupname.
Upvotes: 13