• Register
0 votes
138 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.9k 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

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

 

15.3k points
edited by

Related questions

0 votes
1 answer 27 views
27 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 57 views
57 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 99 views
99 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
1 vote
1 answer 38 views
38 views
Problem : I have recently started to learn the GIT. I was working on my GIT and suddenly I started facing below error. &ldquo;Fatal: not a git repository (or any of the parent directories): .git&rdquo; As I am very new to GIT so I am unable to understand above error ... the error from past couple of days but unable to fix it. Is there anyone who can spare some time and guide me to fix above error?
asked Mar 30 morrisBson 3.2k points
0 votes
1 answer 28 views
28 views
Problem : Currently I am trying to use TortoiseGit on Windows. But when I want to Clone from a context menu of my standard Windows Explorer, I face below error: Please make sure you have the correct access rights and the repository exists How can I make my git work properly?
asked Jan 10 alecxe 7.5k points