Dynamically set user groups for directories and files on a directory

Solution 1:

You can set the setgid sticky bit on the directory to ensure that all new files in the directory will have their group set to the group of the directory.

To do that, run chmod g+s DIRECTORY, where DIRECTORY is the name of your directory.