Joakim Nygård Archive Linked About

Setting Up A Shared Git Repository

25 Oct 2010

There’s been much talk about the version control system git, in great part thanks to github. At the office, we put almost everything under version control (either explicit or implicit through Google docs). It just makes sense when more people are working on the same files.

To make git work for us, we need it to work a little bit more like svn than it usually does. Specifically we want a central, shared repository on a server to commit our individual changes to. It turns out this is very easy to do:

  1. Initialize a new repository on the server. This will create a bare repository (not a checkout) shared between users of the same group. We added ourselves to a new developers group.

    git init --bare --shared=group projectname.git

  2. Make sure the group is correct so all developers have access. Replace $group with your group name.

    chgrp -R $group projectname.git

  3. After cloning the repository and making a few changes, pushing the changes to the shared repository:

    git push origin master

This is only needed the first time. After that a git push is enough, as long as there is only one branch.