I'm sharing a git repository with a friend over SSH. He pushes from and pulls to his git repository using my machine's SSH server, where the shared git repository is.
Problem is that when he pushes a commit, I can't pull, because the commit is janito users rwx------
(these are permission metadata).
I created a group called git, added him and myself, and the repository is jpmelos git rwxrwx---
. How can I force files created in the repository directory to be <creator> git rwxrwx---
as well, so we can always pull and push without worrying about permissions?
Or you can suggest better solutions to the problem, of course. Restrictions are that we need to use the SSH on my machine (we are not ready to make the code public yet) and we are already pushing and pulling from a bare repository I created separately from my working repository.
Thanks!
Best Answer
The umask issues can be taken care with the
core.sharedRepository
Git configuration variable:Whenever Git creates a new file or directory, it will make sure the group bits are set appropriately (always group readable, group writable and executable when appropriate—even if the invoking user’s umask is overly “wide”).
Note: The
core.sharedRepository
setting only applies to entries Git itself makes, so it will not help set the permissions of entries in the working tree of a non-bare repository. You will have to set your umask manually for that.You can make new files and directories be group-owned by your
git
group by setting the setgid bit on the directories (afterchgrp
ing the file and directories to the appropriate group).If you are creating a new repository from scratch, you can just
chgrp
an empty directory and rungit init --shared
on it (Git will setcore.sharedRepository
and do thechmod g=rwxs
on the GIT_DIR):