How to prevent ssh git push to set file ownership?

Solution 1:

Would the SUID and SGID bits help you? I use a similar mechanism to allow members of the bzr group to commit files to a bazaar central repo and still keep the accessible permissions.

drwsrwsr-x  3 bzr          bzr          4.0K 2010-04-15 17:58 bzr

set with sudo chmod ug+s /home/bzr

/etc/group contains bzr:x:1012:bzr,tom,<and a whole bunch of other usernames>

This seems to work pretty well for us, allowing users in the bzr group to commit files to the central repository.

Setting mode 777 probably isn't ideal, for the obvious security reasons.

If I've missed the point, oops.

Solution 2:

Check out the core.sharedRepository config variable in git config --help. Setting it to group might do the trick.

Another option might be to use something like gitosis to manage the repository.