How to set up Gitolite on Ubuntu 10.10

How to set up Gitolite on Ubuntu 10.10

Sometimes it may look like a simple process, however I think that it is always handy to have a guide in hand to take a peak at when you are installing a system. That’s why I am writing this blog post right now, to create a layout for installing Gitolite.

To start off, I will give you a brief description of what Gitolite actually is. You like using Github or Sourceforge as your repository destinations but however, you have projects that needs to be kept in local network and not publicly reachable. For this purpose, you need a software like Gitolite in order to maintain and administer your git repositories. You can create repositories and set their read, write, clone, pull etc. permissions according to users or user groups. Mostly, ssh-keygen pairs are used to authenticate the users to the system.

So where to start now? I will be giving instructions to install Gitolite on a clean Ubuntu 10.10 system, in which I think without a hassle you can do it on other Ubuntu releases. Firstly, you need git and apache2 packages installed in your computer from your Ubuntu repository as well as apache2 server. In order to do that:

sudo apt-get install apache2 git

Now, you need to generate a ssh-keygen pair if you don’t have one already in your hand. Ssh-keygen pairs are located in your users home directory under the hidden directory .ssh. Path is like the following “~/.ssh”. If you don’t have ssh-keygen pair already use the following command:

ssh-keygen -t rsa

Now as you have your key pairs, copy your public key to your /tmp directory in a format of your name and surname as in the example. Public key has an extension of “.pub” and named “” in our case. After copying, also set the read and write permissions for this file.

sudo cp ~/.ssh/ /tmp/
sudo chmod 666 /tmp/

Now, you can download the latest version of Gitolite from Github. It is address is . Download it and unzip it to your ~/src directory. You can create the src directory if you don’t have one already. Move your gitolite directory to here and change its name to “gitolite” for the sake of readability. Then get in the gitolite directoy:

cd ~/src/gitolite

When you are in there, you need to change your user as root,

sudo su

After that, while you are in your gitolite directory, use the following command:

After that process is complete, now we need to create a user named "git" with a home directory of /home/git :

adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git

Now, lets get out of root user and change our user to git:

su - git

If you need to change the password for user git, you can use the following command:

sudo passwd git

While you are the user "git" and in its home directory (/home/git) use the following command which utilizes your previously created public ssh-key:

gl-setup /tmp/

When the setup starts, it will ask you if you need to change .gitolite.rc. Just don't change anything and continue. After the setup is completed, while you are still in your git user, lets set its username and email for git:

git config --global "git"
git config --global your@email

Now you can get out of user git and get back to your regular user using the "exit" command. I like to use my ~/src folder so, I will now get into that directory and clone my gitolite admin repository so that I can create new repositories and users.

cd ~/src
git clone git@localhost:gitolite-admin

I used localhost here as the server address, assuming that your computer is your server, however, if you set up your gitolite on a remote server you need to put hostname or IP of the server instead of localhost.

Now at this point technically, we completed our setup for gitolite. Now you are ready to create new repositories and handle user permissions.

I would also like to give you some administration overview. When you pulled the gitolite-admin repository, now you have 2 different directories in your gitolite-admin directory. One is named "keydir" and the other is called "conf". If you want to add new users to your repositories, you need to put their public ssh-keys in keydir directory under their username. In conf directory, you have a file named gitolite.conf where you mainly do your administration activities. To create a new repo, you can follow the following format:

repo test_repo
          RW+ = admin
          R      =@all

This configuration will result in read write and non-fast forward push rights to your and read permission to all the users in your git repository. Now you are all ready to use your gitolite for you own private repositories.

One thought on “How to set up Gitolite on Ubuntu 10.10

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.