Interview Prep/Git & GitHub/Repository Health, Size and Performance

Pushing to a shared bare repo on a server fails with `error: insufficient permission for adding an object to repository database ./objects`.

IntermediateTroubleshootingRepository Health, Size and Performance
Answer

Likely causes → Several Unix users push over SSH to the same bare repo, and someone created object directories with a private umask (or ran Git as root), so others cannot write there.

Diagnose →

ls -ld /srv/git/app.git/objects/*/ | awk '{print $1, $3, $4}' | sort | uniq -c
git -C /srv/git/app.git config core.sharedRepository

Fix →

cd /srv/git/app.git
git config core.sharedRepository group
sudo chgrp -R developers .
sudo chmod -R g+rwX .
sudo find . -type d -exec chmod g+s {} +

Prevent → Create shared repos with git init --bare --shared=group, never operate on them as root, and prefer a Git server (GitHub, GitLab, Gitea) over raw shared accounts.

All Git & GitHub questions Roadmap: Git & GitHub

More on Repository Health, Size and Performance