Setup Gitolite on Ubuntu (Maverick)

Below is a quick guide to installing Gitolite on Ubuntu.

  1. Create an SSH public/private key pair

    [user@client ~]$ ssh keygen -t rsa
    
  2. Upload the public key to the server

    [user@client ~]$ scp ~/.ssh/id_rsa.pub user@server.example.org:/tmp/user.pub
    
  3. SSH to the server and become root

    [user@client ~]$ ssh user@server.example.org
    user@server:~$ sudo su -
    
  4. Install gitolite

    root@server:~# apt-get install gitolite
    
  5. Switch to the gitolite user

    root@server:~# su - gitolite
    
  6. Run the Gitolite setup script

    gitolite@server:~$ gl-setup /tmp/user.pub
    
  7. From your client computer clone the gitolite-admin repository

    [user@client ~]$ git clone gitolite@server.example.org:gitolite-admin
    Cloning into gitolite-admin...
    remote: Counting objects: 6, done.
    remote: Compressing objects: 100% (4/4), done.
    remote: Total 6 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (6/6), done.
    
  8. Switch to the gitolite-admin directory

    [user@client ~]$ cd gitolite-admin
    
  9. Create a test repository

    [user@client gitolite-admin]$ vim conf/gitolite.conf
    [user@client gitolite-admin]$ git commit -a -m "Add test repository"
    [user@client gitolite-admin]$ git a
    [master 507045a] Add test repository
     1 files changed, 3 insertions(+), 0 deletions(-)
    [user@client gitolite-admin]$ git push
    Counting objects: 7, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (4/4), 376 bytes, done.
    Total 4 (delta 1), reused 0 (delta 0)
    remote: Already on 'master'
    remote: creating test...
    remote: Initialized empty Git repository in /var/lib/gitolite/repositories/test.git/
    To gitolite@server.example.org:gitolite-admin
       87cc470..507045a  master -> master
    
  10. Clone the test repository

    [user@client ~]$ git clone gitolite@server.example.org:test
    Cloning into test...
    warning: You appear to have cloned an empty repository.
    
  11. Add a README file to the test repository

    [user@client test]$ echo "Test Repo" > README
    [user@client test]$ git commit -a -m "Initial commit"
    [master (root-commit) 4a49ee0] Initial commit
     1 files changed, 1 insertions(+), 0 deletions(-)
     create mode 100644 README
    
  12. Push the changes to the server

    [user@client test]$ git push origin master
    Counting objects: 3, done.
    Writing objects: 100% (3/3), 218 bytes, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To gitolite@server.example.org:test
     * [new branch]      master -> master
    

Check out the Gitolite wiki for more documentation.

Profile Management with Git and GitHub

The following describes a simple way to manage you profile configuration files using GitHub.

Features

  • Centralized configuration management
  • Files live in their native locations (no symbolic linking)
  • Home directory is not a Git repository
  • All the power of git with a simple alias

Setup Repository

  • Log into GitHub and create a repository named config
  • Add your public keys to GitHub (if you haven't done so already)
  • Open a terminal and switch to your home directory

    cd ~
    
  • Create a configuration directory

    mkdir .config.git
    
  • Add the following alias to your current session and your .bash_profile

    alias config='git --git-dir=$HOME/.config.git/ --work-tree=$HOME'
    echo "alias config='git --git-dir=$HOME/.config.git/ --work-tree=$HOME'" >> .bash_profile
    
  • Add your .bash_profile to the configuration repository

    config add .bash_profile
    
  • Commit the changes

    config commit -m 'Initial commit'
    
  • Change the origin to GitHub

    config remote add origin git@github.com:GITHUB_USERNAME/config.git
    
  • Push the changes

    config push origin master
    

If you get an error when running config pull to the effect of You asked me to pull without... run the follow:

    echo -e '[branch "master"]\n  remote = origin\n  merge = refs/heads/master' >> ~/.config.git/config

Setup Configuration Management on a Different System

  1. Add your public keys to GitHub (if you haven't done so already)
  2. Switch to your home directory

    cd ~
    
  3. Backup your local configuration files, example:

    mv .bash_profile .bash_profile.bk
    
  4. Clone your configuration repository

    git clone git@github.com:GITHUB_USERNAME/config.git config.git
    
  5. Move the git metadata to ~/.config.git

    mv config.git/.git .config.git
    
  6. Enable dotglob

    shopt -s dotglob
    
  7. Move your configuration files to your home directory

    mv -i config.git/* .
    
  8. Delete the config.git directory

    rmdir config.git
    
  9. Logout and log back in

Basic Usage

  • config pull - get latest configuration changes
  • config add FILENAME - add a configuration file
  • config commit -a - save all configuration changes
  • config push - push configuration changes to GitHub
  • and any other config GIT_OPTION

You can see my configuration repository at http://github.com/silas/config.

Source: Manage your $HOME with git by Robert Escriva