Back

Explore Courses Blog Tutorials Interview Questions
+6 votes
2 views
in DevOps and Agile by (19.4k points)
When I try to push to a shared git remote, I get the following error: insufficient permission for adding an object to the repository database.

Then I read about a fix here: Fix This worked for the next push since all of the files were of the correct group, but the next time someone pushed up a change it made a new item in the objects folder that had their default group as the group. The only thing I can think of is to change all of the developer's default group for items they check-in, but that seems like a hack. Any ideas? Thanks.

2 Answers

+6 votes
by (27.5k points)

Perform these commands from the project root,

cd .git/objects

ls -al

sudo chown -R yourname:yourgroup *

You can tell what yourname and yourgroup should be by looking at the permissions on the majority of the output from that ls -al command

Don't miss the asterisk '*' at the end of the sudo line

+6 votes
by (62.9k points)

Repair Permissions

After you have found and fixed the underlying cause see the below code, to repair the permissions:

cd /path/to/repo.git

sudo chgrp -R groupname .

sudo chmod -R g+rwX .

find . -type d -exec chmod g+s '' +

Note if you want everyone to be able to modify the repository, you don't need the chgrp, so you will remove it and you will want to change the chmod to sudo chmod -R a+rwX .

So, if you do not fix the underlying cause, the error will keep coming back and you'll have to keep re-running the above commands over and over again.

Underlying Causes

The error could be caused by one of the following:

  • The repository isn't configured to be a shared repository (see core.sharedRepository in git help config). If the output of:

git config core.sharedRepository

is not group or true or 1 or some mask, try running:

git config core.sharedRepository group

and then re-run the recursive chmod and chgrp (see "Repair Permissions" above).

The OS does not interpret a setgid bit on directories as "all-new files and subdirectories ought to inherit the group owner". When core.sharedRepository is true or group, Git relies on a feature of GNU OSs (e.g., every Linux distribution) to make sure that the newly created subdirectories are owned by the correct

group (the group that each one of the repository's users is in).

This feature is documented within the gnu Coreutils documentation

Browse Categories

...