• Register
0 votes

Problem :

When ever I try to push to a shared git remote I get the following error
remote: error: insufficient permission for adding an object to repository database ./objects
6.9k points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :


Please go to your project root and follow following steps:

cd .git/objects
ls -al
sudo chown -R yourname:yourgroup *

You need to specify what your name and your group should be by just looking on the permissions on the majority of the output from  ls -al command

Please Note: * at the end of the sudo line is very important

38.6k points
0 votes


After you have identified and correct the underlying reason, you'll want 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 in case you want everyone to be able to tempeer the repository, you don't require the chgrp and you will want to change the chmod to sudo chmod -R a+rwX .

In case you do not correct the underlying reason, the error will remain coming back and you'll have to remain re-running the above commands over and over again.

Underlying Reasons

The error could be involved by one of the following:

The repository isn't configured to be a shared repository . In case the output of:

git config core.sharedRepository

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

git config core.sharedRepository group

and then re-run the recursive chmod and chgrp.

The operating system doesn't explain a setgid bit on directories as "all new files and sub directories must follow the group owner".

At the time core.sharedRepository is true or group, Git relies on a feature of GNU operating systems (for example- every Linux distribution) to aasure that newly made sub directories are owned by the correct group . This property is documented in the GNU coreutils documentation:

In case a directory's set-group-ID bit is set, recently made subfiles follow the same group as the directory, and recently made subdirectories follow the set-group-ID bit of the parent directory. Users share files more effortlessly, by lessening the require to employ chmod or chown to share new files.

But, not all operating systems have this feature ( one example is NetBSD ). For those operating systems, you must ensure that all of your Git users have the same default group. Possibly, you can create the repository world-writable by running git config core.sharedRepository world .

The file system doesn't support the setgid bit (for example FAT). ext2, ext3, ext4 all support the setgid bit. As far as I know, the file systems also don't support the concept of group ownership so all files and directories will be owned by the same group anyhow . In this instance, ensure all Git users are in the group that owns all the files in the file system.

Not all of the Git users are in the same group that owns the repository directories. Ensure the group owner on the directories is correct and that all users are in that group.

If You are using Ubuntu (or any Linux)

From project root,

cd .git/objects
ls -al
sudo chown -R yourname:yourgroup *

You can say what your name and your group must be by looking at the permissions on the majority of the output from that ls -al command

Note: Keep in mind the star at the end of the sudo line

Employ the following command, performs like magic

sudo chown -R "${USER:-$(id -un)}" .


31.7k points
edited by