When I try to push to a shared git remote, I get the following error:
insufficient permission for adding an object to repository database
Then I read about a fix here: Fix This worked for the next push, since all of the files were of the correct group, but the next time someone pushed up a change it made a new item in the objects folder that had their default group as the group. The only thing I can think of is to change all of the developer's default group for items they check in, but that seems like a hack. Any ideas? Thanks.
Linux, macOS:
where
name
is your username andgroup
is the group that your username belongs to.A good way to debug this is the next time it happens, SSH into the remote repo, cd into the objects folder and do an
ls -al
.If you see 2-3 files with different user:group ownership than this is the problem.
It's happened to me in the past with some legacy scripts access our git repo and usually means a different (unix) user pushed / modified files last and your user doesn't have permissions to overwrite those files. You should create a shared git group that all git-enabled users are in and then recursively
chgrp
theobjects
folder and it's contents so that it's group ownership is the sharedgit
group.You should also add a sticky bit on the folder so that all the files created in the folder will always have the group of
git
.Update: I didn't know about core.sharedRepository. Good to know, though it probably just does the above.
I hit this same issue. Reading around here I realised it was file permissions the message was referring to. The fix , for me, was in:
/etc/inetd.d/git-gpv
It was starting git-daemon as user 'nobody' so lacked the write permission.
(I doubt other call their inetd conf file git-gpv . Commonly it would be directly in /etc/inetd.conf)
After you add some stuff... commit them and after all finished push it! BANG!! Start all problems... As you should notice there are some differences in the way both new and existent projects were defined. If some other person tries to add/commit/push same files, or content (git keep both as same objects), we will face the following error:
To solve this problem you have to have something in mind operational system's permissions system as you are restricted by it in this case. Tu understand better the problem, go ahead and check your git object's folder (.git/objects). You will probably see something like that:
*Note that those file's permissions were granted only for your users, no one will never can changed it... *
SOLVING THE PROBLEM
If you have super user permission, you can go forward and change all permissions by yourself using the step two, in any-other case you will need to ask all users with objects created with their users, use the following command to know who they are:
Now you and all file's owner users will have to change those files permission, doing:
After that you will need to add a new property that is equivalent to --shared=group done for the new repository, according to the documentation, this make the repository group-writable, do it executing:
https://coderwall.com/p/8b3ksg
You need the sufficient write permissions on the directory that you are pushing to.
In my case: Windows 2008 server
right click on git repo directory or parent directory.
Properties > Sharing tab > Advanced Sharing > Permissions > make sure the user has appropriate access rights.
For Ubuntu (or any Linux)
From project root,
You can tell what yourname and yourgroup should be by looking at the permissions on the majority of the output from that ls -al command
Note: remember the star at the end of the sudo line