Git Setup with SSH

This is just a simple rundown of how to setup git properly for SSH use. SSH specific information about how to connect using SSH keys, and things of that nature, are not within the scope of this post. I will update this as I go.

1. To ensure that you are creating repositories with the correct permissions, you need to set the git config variable core.sharedRepository on the server.  You need the –system, so that it gets stored in /etc/gitconfig.

 git config --system core.sharedRepository group

2. Setup your git commit notification.

After that, it’s just a matter of chowning your repo to the correct group on the server.  If you didn’t originally create your repos with proper group permissions, you’re going to have to do that.

chown -R :group /home/git/myrepo
find /home/git/ -type d | while read -r dir; do chmod g+s "$dir"; done
find /home/git/ -type f | while read -r file; do chmod g+rw "$file"; done