Shared Git repository tutorial

February 24th 2013 by Samuel Rossille

This is a simple and straightforward step by step method to setup a shared git repository for a small team. It uses the ssh protocol to communicate with the server. The server must be a linux OS. Pros: Very simple to setup and to administrate. Constraints: You must have a user for each developper, and your network configuration must allow the developpers to access the server through SSH.


Step 1: Install git on your server Step 2: Create the directory for the repository. A conventionnal location for a git repository named "myrepo" is /var/git/myrepo.git

mkdir /var/git
mkdir /var/git/myrepo.git

Step 2: Create a user group to control access to the repository

groupadd myrepogit

Step 3: Add users to the git repository control group

usermod -a -G myrepogit alloweduser1
usermod -a -G myrepogit alloweduser2
usermod -a -G myrepogit alloweduser3

Step 4: Define the control group as owner of the repository

chown root:myrepogit /var/git/myrepo.git

Step 5: Finally, initialize the repository

cd /var/git/myrepo.git
git init --bare --shared=0660

The \--shared=0660 option will create a repository that's readable and writable by users of the group and nobody else

Cloning the repository

You're all set. Your developpers can now clone the repository and start to pull and push

git clone ssh://