- Yes it is possible for users to access files in another users home directory.
- No, there is no special treatment of home directories outside the system file permissions. "Giving rights to a group" involves two parts, granting group ownership, and setting group permissions. Your example deals only with ownership.
You can set permissions recursively with the chmod command but that alone may not guarantee that new files created by one member of the group will be accessible to the others.
Thank you for the account of what you've done so far, with adequate details, and for stating your goal to share git repositories.
Let's first look at how to accomplish group file sharing on Unix and Linux in a general way, and then look at some considerations for git.
Basic Group File Sharing Configuration
Here are some basics of this type of file sharing in Unix and GNU, etc. This is a simple way to set up a one or more directories where all members of a group have read and write permissions on files created by other users in the group.
Let's assume your common user group will be gitusers and the directory is repo.
Put sharing members into a common group (for example gitusers).
Set umask 002 for all of the users in the group, indicating that most files will be created group-writable by default. This may be set in various shell startup files (such as /etc/bash.bashrc). On GNU/Linux systems see man 8 pam_umask and man umask for more and better information.
Set group ownership recursively (-R) on all shared files:
chgrp -R gitusers repo
Set group read and write permissions recursively on all files:
chmod -R g+rw repo
Set the set group id on execution bit (setgid) of repo and all subdirectories. The setgid indicates that newly created files and subdirectories in that directory inherit the same group ownership as the parent directory. New subdirectories also have the setgid bit set, for a recursive effect:
find repo -type d -exec chmod g+s {} \;
After the above steps, you should be well on your way for all users in the same group gitusers in the example, to read and write each other's files, while disallowing write permission for users not in the gitusers sharing group. You can replicate the chown, chmod and find command on as many directories as you wish, for any sharing purpose you wish, not just git.
Sharing git Repositories
It appears that git may work OK with only the above configuration changes. However git also knows about sharing and group permissions (and may actually do some of the above for you).
If you're creating a shared git repository, consider these options:
git init --bare --shared=group repo
If you have an existing repository, consider these settings:
- core.bare
- core.sharedRepository=group
See the git-init man page and the git-config man page for more details.
Notes
While a bare, group-shared git repository will take care of some of the same steps as in the general example, I would recommend performing the steps in the general example as well to ensure consistency and also ease in setting up any other shared directories.