From my local git, I push to my private remote repo (via ssh), where I would like all files to be stored without any permissions for group, and in particular without access for others.
I have attempted to help myself by setting an git internal umask overwrite in the configs of the remote git
the relevant setting in remotes .git/config
[core]
sharedRepository 0600
which I thought to mean. "Hey git whenever you do a checkout, would you be so kind and set 6 (rw permissions to the file owner), and 0 (no permissions at all to group and others).
The version of git used on the remote side is 2.7.4.
This did however not work out. Several times I pushed new files to the remote (non-bare) git repo, which when eventually checked out there, are checked out with world readability set.
Other attempt
Additionally I thought that I could set the umask in the pre-receive hook script.
.git/hooks/pre-receive
content is
#!/bin/bash
umask > /umask.at.pre-receive
umask 0077
exit 0
the script gets successfully executed upon push, however the desired effect that all files written (including the objects, the .git
folder content etc) would be have permissions uset for (group and others).
update
Some answer (which has in the meantime been removed) implied (to my understanding), that the problem might be that core.sharedRepository
setting does only work locally. Consequently when working remotely a call o git push
, will not trigger the remote side to use the settings of core.sharedRepository
.
Also the answer suggested to look into smudge-filters, as those would allow to change the files before they are checked out. Maybe this can be a partial solution to the problem depicted in this question.