i created a bare repo @

/srv/repos/test

i set ownership to wwwrun:www with SUID+GUID bits set

chown -R wwwrun:www /srv/repos/hub
chmod ug+s          /srv/repos/hub
ls -ald /srv/repos/test
    drwsrws---+ 10 wwwrun www 4.0K Mar  7 21:28 /srv/repos/hub/

i cloned the repo to a webroot, and changed its ownership,

git clone /srv/repos/hub /srv/www/siteA
chown -R wwwrun:www      /srv/www/siteA

for convenience, I define a remote

cd /srv/www/siteA
git remote add HUB /srv/repos/hub

then create post-commit and post-update hooks to keep things in sync,

vi /srv/www/siteA/.git/hooks/post-commit
    #!/bin/sh
    git push HUB

vi /srv/repos/hub/hooks/post-update
    #!/bin/sh
    cd /srv/www/siteA || exit
    unset GIT_DIR
    git pull HUB master
    exec git-update-server-info

as my normal user, i checkout HUB

whoami
    locuse
cd ~
git clone /srv/repos/hub WORK
ls -ald WORK
    drwxr-xr-x 10 locuse users 4.0K Mar  7 21:44 WORK/

make a change, commit and push,

cd WORK
touch touch_file
ls -al touch_file
    -rw-r--r-- 1 locuse users 0 Mar  7 21:44 touch_file
git add -A
git commit -m "add test"
git push

then checking to see that the hook fired and the update was pushed to the webroot,

ls -al /srv/www/siteA/touch_file
    -rw-rw----+ 1 locuse www 0 Mar  7 21:45 /srv/www/siteA/touch_file

the file's there -- as expected.

but, it's not the user-ownership i want, namely it's user='locuse' not user='wwwrun'.

in this specific use-case, what's the right way to make sure that i, INSTEAD, would always automatically end-up with,

ls -al /srv/www/siteA/touch_file
    -rw-rw----+ 1 wwwrun www 0 Mar  7 21:45 /srv/www/siteA/touch_file

? i.e., everything always gets promoted to

Edit
Report