In order to install gitosis, we need Git itself. Let’s install it first:
apt-get install git-core
Next, we clone the gitosis repository and build gitosis itself:
cd /tmp git clone git://eagain.net/gitosis.git sudo apt-get install python-setuptools cd gitosis sudo python setup.py install
Now we add the git user:
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
We need a gitosis administrator. Copy your public key (if you have one) to the server’s /tmp directory and type the following:
sudo -H -u git gitosis-init < /tmp/id_rsa.pu
If you do not have a private/public key pair, generate it using ssh-keygen.
At this point, the bare gitosis-admin repository has been created in the git home directory.
A small adjustment to make the post commit hook executable:
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
From here, you can work on your local machine (not the server). Pick a directory to create the administration repository in and execute the following:
git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
Cd into gitosis-admin and add repositories and users. You add repositories in the gitosis.conf file:
[group webxplode] writable =webxplode members = janos@aurum
Separate the members with space. For each member, there has to be a corresponding public key in keydir. The name must be member name + .pub. So for example, if the user is called janos, the file name for the key must be janos.pub.
Once you made changes to gitosis.conf and added keys to keydir (if you added users), commit and push the changes to the server:
git commit -a -m 'added repositories'
This will commit the changed gitosis.conf file and any changed or newly added public keys in keydir.
The last step is to push the changes to the server:
git push origin master
Now you can clone any of the repositories you just defined:
git clone git@server:webxplode.git
Now you can use the repository webxplode.