• Register
0 votes
173 views

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 5 3
6,930 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

Ubuntu/Linux

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

9 7 4
38,600 points
0 votes

Solution:

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)}" .

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 34 views
34 views
Problem : git - Your branch is ahead of 'origin/master' by 1 commit
asked Feb 15 Shovo210 13.2k points
0 votes
1 answer 77 views
77 views
Problem : I am unable to clone my Git repository and getting below error: ​/c/Projects $ git clone http://stage.abc.com:10088/pqr http://<url>/<repository> Cloning into '<repository>'... fatal: could not read Username for 'http://<url>': No such file or directory ​ How can I fix the above error?
asked Jan 16, 2020 jwilliam 3.9k points
1 vote
1 answer 129 views
129 views
Problem : I am unable to clone my Git repository, and getting below error: /c/Projects $ git clone http://stage.abc.com:10088/pqr http://<url>/<repository> Cloning into '<repository>'... fatal: could not read Username for 'http://<url>': No such file or dir Please let me know any pointers to resolve my error.
asked Dec 30, 2019 alecxe 7.5k points
0 votes
1 answer 2 views
2 views
Problem: Icould not read from remote repository git clone and getting the above eror . can somebody help?
asked 2 days ago Sana8989 7.7k points
0 votes
1 answer 2 views
2 views
Problem: Please somebody help to figure out the solution of the issue:error typeerror: cannot read property 'push' of undefined.
asked Apr 4 ashik 10.6k points
1 vote
2 answers 283 views
283 views
Problem : I need solution for bellow GIT error another git process seems to be running in this repository, e.g. an editor opened by 'git commit'.
asked Nov 8, 2019 peterlaw 6.9k points
0 votes
1 answer 3 views
3 views
Problem What can I do to solve this problem, "Failed to connect to repository : error performing command:?"
asked 3 days ago salim1 30.7k points
0 votes
1 answer 20 views
20 views
Problem: Auto packing the repository in background for optimum performance.
asked Feb 13 Shovo210 13.2k points
0 votes
1 answer 25 views
25 views
Problem : Error &ldquo;push master to origin/master was rejected by remote&rdquo;
asked Feb 23 Shovo210 13.2k points
0 votes
1 answer 7 views
7 views
Problem: I have a project hosted on GitHub. I fail when trying to push my modifications on the master. I always get the following error message Password for 'https://*Emails are not allowed*': remote: Invalid username or password. fatal: Authentication failed for 'https://*Emails are not allowed*/eurydyce/MDANSE.git/
asked Mar 30 ummesalma 21.9k points