Until now I managed my code/work with Subversion and all was very well, but I decided to move to a distributed revision control system. Calling spade as a spade my choice was Git.
After some tests I had the problem, that there is (basically) no central repository where everyone can commit changes, but I’m working with other guys on homework/projects. So how to centralize a distributed revision control system?
Nothing easier than that!
Server set up
Software of choice is called gitosis, so install the following:
Gitosis will manage repositories and privileges on the repository server. The installation progress will add a new user to your system called gitosis (see /etc/passwd ). To initialize the master repository that will manage the rest just copy the SSH public key of your local account to /tmp/id_rsa.pub and do the following:
That’s it on the server, now you have a head-repository and you can manage everything on your local machine.
Managing the manage-repository
Right back on your local machine you also have to install Git:
Now you’re able to check out the previous created managing repository that knows your SSH key:
The directory keydir holds known SSH keys from users that will work with you, gitosis.conf is the managing file. It is nearly empty on creation and may look like this:
To add a new repository just type something like this:
And to create a new group of users:
New users should give you their public key, so you can save it in the keydir directory with a name like firstname.lastname@example.org .
To commit the changes you’ve made type the following:
Now everybody that was enabled is allowed to checkout your projects. To initiate a new project you can do the following:
To commit a first file:
Voila, there is your repository! Check it out, change it, branch it, you know what to do!
Publish a repository
With this configuration only you and a bunch of people can see what you are doing in your spare time, but what if you want to publish you work? You can create a git daemon that listens on port 9418 of your server, waiting for a user who wants clone your code:
This service will serve any repository content if you create a file called $REPOSITORYHOME/git-daemon-export-ok in this repository (content isn’t necessary). Everybody knows that such a daemon tends to die sometimes, so I created a cronjob:
Now everybody can clone repositories with that special file that allows public cloning by:
That’s it! not that difficult but one has to know what to do!
Have fun with your repository.