Skip to content

Installing and Administer a Git Server using GitoLite

GitoLite is a simple Git server that can handle user authentication per project / branch. Even though I don’t mind too much to shell out $300 bucks for a simple business plan with GitHub I want to keep my code closer to my heart that anything else. Even though I don’t think that my server is tightly protected it is at least my fault when something goes wrong. Lately there have been reports of nasty security breaches on user data servers and even Dropbox had their account unprotected for a few hours.

The first thing I was surprised of was the fact that there is no out-of-the-box git server available as it is with Subversion. Then I tried Gitosis but ran into issues with Python and abandoned that. Later I heard about GitoLite which gave me some grief at the beginning but eventually I could make it work out. The trick was to make sure that I was focuses on the task and made sure only to proceed if the previous step worked out.

To install Gitolite you need to follow these steps and make sure that all work before go to the next. Unfortunately the error message are cryptic and so it is hard to figure out what is wrong.

The Rules:

  • This installation is tested for Mac OS X Snow Leopard (10.6) Server
  • Make sure that each step worked nicely
  • I tested the installation on a Mac OS X server and on a workstation you need to create the user account yourself. Make sure that you can login as the given user.
  • SSH can be nasty at times so I make sure that it works before going on. This means we need to undo a step later but it is worth while.
  • I could not clone a repository on the server but that is because I forgot to add my SSH public key of the server as well.
  • Gitolite needs your public SSH key file from the workstation where you initially are going to configure the server. This also means that this is the only computer from where you can access the git server until you added new public SSH key files.
  • Keep in mind that for Gitolite a user is a combination of a user and a computer which is represented by the public SSH key. That means that you need to install a public SSH key for every user and every computer they want to access the Git server from. The positive side is that you don’t need to manage passwords because the user is authenticated by the SSH key pair.

Installation Step of GitoLit:

  1. Create a user named “git” on the server with a home directory (assuming “/Users/git”) using WorkGroup Manager
  2. Copy the public ssh key (for example from your local workstation onto the server (use ‘ssh-keygen -t rsa’ to generate one inside the ‘/.ssh’ directory. Make sure that permission is set to “700” on the “/.ssh” directory.
  3. Add the content of your public key file on the server into this file (create one if needed): ‘/Users/git/.ssh/authorized_keys’ and also make sure that the permission on the .ssh directory is set to 700.
  4. On the workstation try to log in using: ‘ssh git@‘. If you can login without entering a password your are good to proceed. Otherwise you need to check the permissions as well as the content of the authorized_keys file that no character was dropped.
  5. Make sure “git” software is installed by executing “git” on the command line (should be there by default)
  6. There is one little problem left. For whatever reason the path to the “git” software was not setup on my server. So create or edit “/Users/git/.bashrc” and add the following lines:
    export PATH=$PATH:/usr/local/git/bin/
  7. Check the path from your workstation with:
    ssh git@<server name> echo $PATH
  8. It must contain ‘/usr/local/bin‘ and ‘/usr/local/git/bin
  9. Attention: the test on 7) must be done before installation Gitolite because afterwards we cannot login as git on the server using SSH (it will give you a list of repos instead)
  10. Login to your server and sudo (sudo -s) to become root
  11. Get the gitolite code:
    git clone git://
  12. Change into the ‘gitolite’ directory and execute this:
  13. Now become user “git” (IMPORTANT) using ‘su git’ (check with ‘whoami’)
  14. Change into the “gitolite/src” directory (from the code cloned above)
  15. Change the name of the public ssh key because Gitolite will use that as name for the virtual user
  16. Execute the setup with:
    gl-setup <path to the renamed public ssh key>
  17. Because Gitolite is also installing the same public ssh key we need to go back to ‘/Users/git/.ssh/authorized_keys’ and delete the line we originally added to test the passwordless login
  18. Now login into the server with SSH (ssh git@ ) should display this:
    PTY allocation request failed on channel 0
    hello schaefa, the gitolite version here is v2.0.2-6-gfda9f37
    the gitolite config gives you the following access:
       R W gitolite-admin
       @R_ @W_ testing
    Connection to closed.
  19. On the workstation checkout ‘gitolite-admin’ with:

    git clone git@<your server name>:gitolite-admin

Next Steps:

The Gitolite server is configured use the clone of the ‘gitolite-admin’ and your workstation and then pushed back to activate it. So for example to create a new repo:

  1. Go to the ‘gitolite-admin/conf’ directory
  2. Open ‘gitolite.conf’ file and add a new repo name together with the users allowed to access it
  3. Commit the changes:
    git commit -a -m "Your Message here"
  4. Push the changes to the server
    git push git@<server name>
  5. You can now clone the new repo using

    git clone git@<server name>:<your new repo name>

To add new users you need to do the following:

  1. Ask the users for a public SSH key (
  2. Rename the file so that it names the user (maybe together with its computer)
  3. Copy that file to ‘gitolite-admin/keydir’ or any sub directory
  4. Gitolite will seach for these files recursively so you can organize them as you like
  5. Open gitolite-admin/conf/gitolite.conf file and add the users to the desired repositories
  6. Commit these changes to your local repo
  7. Push the changes to the server


In case you have problems understanding how GIT works then you might want to check out the book Pragmatic Guide to GIT from the Pragmatic Bookshelf as it gives some ideas how to use it. Anyone coming from Subersion, as I did, will have quite some problems to understand how git works.

Mario noted in the corresponding blog that he ran into issues at point 19) which I did too initially and that is why we did the elaborate check with the PATH setup but there seems to be another issue. Please check out this Stackoverlflow entry.