The Complete Step-by-Step Guide to Installing Gitosis (Part 2)

 

Yesterday we covered how to get Gitosis set up (read the article here). So lets pick up where we left off.

Adding Repositories and User Access

Now I guarantee you’ll be impressed. The gitosis-admin repository is how you manage repositories and user’s access. Open up the directory in your favourite text editor

You’ll see a file called gitosis.conf which will look something like this:

[gitosis]

    [group gitosis-admin]
    writable = gitosis-admin
    members = andy@my_pc.local

And a keydir directory which will contain all the users public keys, for now there’ll just be yours in there. The important thing to note here is that the username needs to be exactly what it says at the end of your public key so in my case it says andy@my_pc_.local. Yours will be different.

Essentially you just create groups with

[group some-arbitary-string]

and then who the members of that group are, separating each member with a space and then which repositories they have access to with the writable key.

So, for example, we have a Foxsoft group, in which we’re all members and I’m going to give us access to three repositories

[group foxsoft]
    members  =  andy@my_pc.local adre@his_computer.local hugh@another_pc.local
    writable = repo_1
    repo_2
    repo_3

How simple is that. Oh yeah, just by adding the repository names to this list will mean that you can just push to them. You can create different groups and give different people access to different (or the same) repositories. To add a user, all you need is their public key and add it to the keydir folder, naming it according to the information at the end of the public key file. You then use this as the members username in the members = key.

When you have added a user or changed the repository settings in any way you just commit the changes as you usually would and then do a git push and suddenly gitosis knows all about it! Those new users can start pushing and pulling to those repositories.

The final step in any complete guide is getting one of your existing repositories up there. Change into the directory of one of your existing repositories then just do

git remote add nickname git@your_server:repo_name.git

Replace nickname, your_server and repo_name as appropriate. The nickname is what you’ll refer to it as so you then can just do

git push nickname master

And you’re done. Anyone else who’s been given write access to this repository in the gitosis-admin can clone it with

git clone git@your_server:repo_name.git

I hope you found this guide useful.

For more information visit these two articles – it’s where I got most of the inspiration and knowledge for doing this myself:
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
http://blog.ardes.com/2008/5/19/git-hosting-with-leopard