After you have found and fixed the underlying cause see the below code, to repair the permissions:
sudo chgrp -R groupname .
sudo chmod -R g+rwX .
find . -type d -exec chmod g+s '' +
Note if you want everyone to be able to modify the repository, you don't need the chgrp, so you will remove it and you will want to change the chmod to sudo chmod -R a+rwX .
So, 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.
The error could be caused by one of the following:
- The repository isn't configured to be a shared repository (see core.sharedRepository in git help config). If the output of:
git config core.sharedRepository
is not group or true or 1 or some mask, try running:
git config core.sharedRepository group
and then re-run the recursive chmod and chgrp (see "Repair Permissions" above).
The OS does not interpret a setgid bit on directories as "all-new files and subdirectories ought to inherit the group owner". When core.sharedRepository is true or group, Git relies on a feature of GNU OSs (e.g., every Linux distribution) to make sure that the newly created subdirectories are owned by the correct
group (the group that each one of the repository's users is in).
This feature is documented within the gnu Coreutils documentation