• Register
0 votes
148 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

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 41 views
41 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 jwilliam 3.9k points
1 vote
1 answer 75 views
75 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
1 vote
2 answers 145 views
145 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 93 views
93 views
Problem: I am having only basic knowledge of git. Now I am trying to clone the project from a gitlab to my own local machine. I have already been granted rights as the developer on it and I have used the command as 'git clone&rsquo;. But none of the ... &ldquo;Remote: The project you were looking for could not be found.&rdquo; Any help in fixing my git related error would be highly appreciated.
asked Sep 4 Raphael Pacheco 4.9k points