Skip to content

Instantly share code, notes, and snippets.

@claudioovp
Last active April 24, 2018 18:44
Show Gist options
  • Save claudioovp/21ba5d1757d54b61e2cb7ff6ba6654b3 to your computer and use it in GitHub Desktop.
Save claudioovp/21ba5d1757d54b61e2cb7ff6ba6654b3 to your computer and use it in GitHub Desktop.
Configure an existing git repo to be shared by a UNIX group

It is for bare repos and non-bare repos. There are only little differences between them, but in this way is clearer.

BARE REPOSITORY

cd <repo.git>/                            # Enter inside the git repo
git config core.sharedRepository group    # Update the git's config
chgrp -R <group-name> .                   # Change files and directories' group
chmod -R g+w .                            # Change permissions
chmod g-w objects/pack/*                  # Git pack files should be immutable
find -type d -exec chmod g+s {} +         # New files get directory's group id

where:

  • <repo.git> is the bare repository directory, typically on the server (e.g. my_project.git/).
  • is the group name for git users (e.g. users).

NON-BARE REPOSITORY

cd <project_dir>/                         # Enter inside the project directory
git config core.sharedRepository group    # Update the git's config
chgrp -R <group-name> .                   # Change files and directories' group
chmod -R g+w .                            # Change permissions
chmod g-w .git/objects/pack/*             # Git pack files should be immutable
find -type d -exec chmod g+s {} +         # New files get directory's group id

where:

  • <project_dir> is the project directory containing the .git folder.
  • is the group name for git users (e.g. users).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment