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.
For my case none of the suggestions worked. I'm on Windows and this worked for me:
git remote add foo //SERVERNAME/path/to/copied/git
)git push foo master
. Did it worked? Great! Now delete not-working repo and rename this into whatever it was before. Make sure permissions and share property remains the same.Repair Permissions
After you have identified and fixed the underlying cause (see below), you'll want to repair the permissions:
Note if you want everyone to be able to modify the repository, you don't need the
chgrp
and you will want to change the chmod tosudo chmod -R a+rwX .
If you do not fix the underlying cause, the error will keep coming back and you'll have to keep re-running the above commands over and over again.
Underlying Causes
The error could be caused by one of the following:
The repository isn't configured to be a shared repository (see
core.sharedRepository
ingit help config
). If the output of:is not
group
ortrue
or1
or some mask, try running:and then re-run the recursive
chmod
andchgrp
(see "Repair Permissions" above).The operating system doesn't interpret a setgid bit on directories as "all new files and subdirectories should inherit the group owner".
When
core.sharedRepository
istrue
orgroup
, Git relies on a feature of GNU operating systems (e.g., every Linux distribution) to ensure that newly created subdirectories are owned by the correct group (the group that all of the repository's users are in). This feature is documented in the GNU coreutils documentation:However, not all operating systems have this feature (NetBSD is one example). For those operating systems, you should make sure that all of your Git users have the same default group. Alternatively, you can make the repository world-writable by running
git config core.sharedRepository world
(but be careful—this is less secure).use the following command, works like magic
type the command exactly as it is (with extra spaces and one dot at the end)
I just wanted to add my solution. I had a repo on OS X that had ownership of root on some directories and Home (which is my user directory) on others which caused the same error listed above.
The solution was simple thankfully. From terminal:
Solved for me... just this:
sudo chmod -R ug+w .;
Basically,
.git/objects
file does not have write permissions. The above line grants permission to all the files and folders in the directory.