This repository has been archived on 2026-07-09. You can view files and clone it, but cannot push or open issues or pull requests.
agent-knowledge-base-archived/problems/2026-05-24-local-git-server-bare-repo-group-permissions.md
2026-05-24 17:47:29 +03:00

2.1 KiB

Local Git Server Bare Repo Group Permissions

Symptoms

Creating or repairing a bare repository under /srv/git as a normal machine user can leave files owned by that user or by root, and a later non-owner chgrp or permission repair can fail with Operation not permitted.

On 192.168.1.66, qore could access the local Git server, but repairing /srv/git/Kamaz_Cleaner.git group ownership from the unprivileged account failed.

Environment

  • Project: garage
  • Host: 192.168.1.66
  • Repository path: /srv/git/Kamaz_Cleaner.git
  • Shared group: stereowallnd
  • Machine users: qore, wuu, pump

Root Cause

Bare repositories intended for multiple SSH users need consistent group ownership, setgid directories, and shared-repository config. A normal member of the shared group may be able to write some objects but cannot fix ownership of files it does not own.

Solution

Run the permission repair as root or another administrative account on the Git server:

for u in qore wuu pump; do
  usermod -aG stereowallnd "$u"
done

install -d -m 2775 -o root -g stereowallnd /srv/git
git init --bare --shared=group /srv/git/Kamaz_Cleaner.git  # only if missing
git --git-dir=/srv/git/Kamaz_Cleaner.git config core.sharedRepository group
chgrp -R stereowallnd /srv/git/Kamaz_Cleaner.git
chmod -R g+rwX /srv/git/Kamaz_Cleaner.git
find /srv/git/Kamaz_Cleaner.git -type d -exec chmod g+s {} +

if command -v setfacl >/dev/null 2>&1; then
  setfacl -R -m g:stereowallnd:rwx /srv/git/Kamaz_Cleaner.git
  setfacl -R -d -m g:stereowallnd:rwx /srv/git/Kamaz_Cleaner.git
fi

Do not store user passwords, SSH private keys, or tokens in Git while doing this.

Verification

  • getent group stereowallnd lists qore, wuu, and pump.
  • ls -ld /srv/git /srv/git/Kamaz_Cleaner.git shows group stereowallnd and setgid directories.
  • git ls-remote ssh://qore@192.168.1.66:22/srv/git/Kamaz_Cleaner.git succeeds.
  • git push --dry-run ssh://qore@192.168.1.66:22/srv/git/Kamaz_Cleaner.git HEAD:refs/heads/<temporary-check-branch> succeeds without modifying the remote.