Gitolite

From DreamHost
Jump to: navigation, search
The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes may cause this to break. Be prepared to troubleshoot this yourself if this happens.
We seriously aren't kidding about this.

Git with Gitolite

Git does not come with any access control out of the box. If you know a URL for a git repository, you can clone and commit to it. Gitolite serves to fill in this gap and provide fine grained access control to git repositories.

Pre-Requisites

This guide assumes that you are using a recent version of linux.

Before you begin you will need the following:

  • A user account on Dreamhost dedicated to gitolite.
    • This account will be used to access the git repo and nothing else
    • After installation you will NOT be able to log in normally for this account. Either log in under a different account and the su, or run ssh with the "-o PubkeyAuthentication=no" or "-o preferredauthentications=password" option.
  • SSH installed on your local machine
  • SSH keys generated for your local machine
    • See SSH for more information
    • NOTE: Do NOT add your RSA public key to .ssh/authorized_keys on the server. Use a password to log in. Adding the public key will break things. Just trust us on this.

Installation

Below is an overview of these directions.

  1. Copy your public key to the server as "git-admin-name.pub". The name chosen here can be anything, but it will be the name of your git admin.
  2. Log into the server.
  3. Ensure that $HOME/bin is in your path. If it isn't, fiddle with the appropriate rc file for your shell to add it. This snippit will take care of it in bash: echo "export PATH=$HOME/bin:$PATH" >> .bashrc; source .bashrc
  4. Run the following commands, replacing git-admin-name.pub with path of your copied public key file:
   cd $HOME
   git clone git://github.com/sitaramc/gitolite
   gitolite/install -ln
   gitolite setup -pk git-admin-name.pub

Gitolite is now installed. You can remove the git-admin-name.pub file if desired.

Admistration

Gitolite administration is NEVER done on the server itself. It is done by cloning the special gitolite-admin repo, making changes, and pushing the changes back to the server.

To clone the gitolite-admin repo:

   git clone username@exampleserver.com:gitolite-admin

Add Users

  1. Obtain public keys from each user.
  2. Rename each received key file to the name of the user, with a ".pub" at the end.
  3. Copy it into keydir/ in the gitolite-admin repo you cloned.
  4. Commit and push the repo:
   git add keydir
   git commit
   git push

You do NOT need to add users as real (Unix) users. You do NOT add their keys directly anywhere on the server; you do it by cloning, adding keys, and pushing.

Add Repos

  1. Edit conf/gitolite.conf in the gitolite-admin repo.
  2. Add repo paragraphs (example below) and save the file.
  3. Commit and push the gitolite-admin repo
   git add conf/gitolite.conf
   git commit
   git push

You do NOT add the repos directly anywhere on the server; you do it by cloning, adding keys, and pushing.

Example repo paragraph:

   repo foo
       RW+     =   alice
       RW      =   bob

Alternatives

References