• Register
0 votes
155 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 54 views
54 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 86 views
86 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 179 views
179 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 434 views
434 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 427 views
1 vote
1 answer 63 views
63 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, 2020 morrisBson 3.2k points
0 votes
1 answer 36 views
36 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, 2020 alecxe 7.5k points
0 votes
1 answer 52 views
52 views
Problem : I am trying to use the TortoiseGit on my Windows. But when I want to Clone it from my context menu of the standard Windows Explorer then I face below error: Please make sure you have the correct access rights and the repository exists In more detail the complete snapshot of ... exit cleanly (exit code 128) (21450 ms @ 17.12.2019 10:36:58) What should I do to make my git work correctly ?
asked Dec 19, 2019 alecxe 7.5k points
0 votes
1 answer 103 views
103 views
Problem: I have fundamental knowledge on Git. I learned Git by watching online video tutorials. I am working on the rails 3.2 and I often receive below error if I try to push to the heroku: git push heroku master Counting objects: 496, done. Delta compression using up ... then deleting and again adding the remote but it is not working for me. I need help from git expert to fix above git error.
asked Jun 17, 2020 Raphael Pacheco 4.9k points
0 votes
2 answers 1.2K views
1.2K views
Problem : I am a beginner to Git . If I do the git push for the first time then it works fine for me and creates the remote branch also. But if I try to push for the second time for some eleventh hour updates then I get the below error: Error: failed to push ... forwards' in 'git push --help' for details. I am struggling with this error from past couple of days. Can somebody guide me in fixing it?
asked Mar 5, 2020 mphil 2.3k points