Oct14 gitosis

From DreamHost
Jump to: navigation, search


This page is meant to compliment the original Gitosis for Dreamhost article with up-to-date instructions. The original version of the article indicates that versions of Git and Python need to be updated, however when I checked the versions available on my Dreamhost server they were newer than the versions the article recommended upgrading to. So I'm posting my steps here, as of yet it isn't working correctly, so perhaps someone can help get this fixed.

Git with Gitosis (as of Oct 14, 2010) - Prerequisites

  • A user account on Dreamhost. This account will be used for the git repositories and nothing else.
  • SSH installed on your desktop computer. Each user of a gitosis managed repository will also require SSH on his desktop computer.
  • The python setuptools package. Setuptools are required to install the gitosis package.
  • A current version of Gitosis. You will retrieve the gitosis package using git.

The procedures here presume your desktop computer is a PC running Linux.

There are two primary accounts to keep in mind.

  • The unix user account on the dreamhost server.

For this tutorial I'll insert the details of my setup. This user is called ft_git. Since I share the server with many other people there is probably another git user already defined...so I prepended my initials to ensure a unique user on the server.

  • The linux user account on my desktop, this happens to be ftravers

In my case, my domain is spicevan.com, please substitute this for whatever your domain is called.

Create a Dreamhost user account

Using your Dreamhost account control panel, create a user account, in this example ft_git, with shell access.

SSH Keys

You need to get your desktop user, ftravers, public ssh key onto the dreamhost server.

[local]$ ssh-keygen -t rsa
[local]$ rcp ~/.ssh/id_rsa.pub ft_git@spicevan.com:~

When I use the syntax: [local]$, I mean this is a command executed on your local desktop. I'll use the syntax [remote]$, when it is a command you should run on the server. If you already have a public/private key pair then the first command will let you know and don't bother over-writing it.

Installing Git

In the original article they indicate you should upgrade git to version 1.6...however my server indicates it's running 1.7, so I skipped this step.

Installing Python

Gitosis requires Python at version 2.4 or higher. My server reports Python 2.5, so again I skipped this step.

Installing Python Install Tools

In this case, I thought I had to do this step so I did it. The below has a bunch of other steps too. These are getting and installing gitosis and initializing gitosis with your ftravers account public key.

[local]$ ssh ft_git@spicevan.com
[remote]$ mkdir -p $HOME/lib/python2.5/site-packages; export PYTHONPATH=$HOME/lib/python2.5/site-packages
[remote]$ mkdir ~/src; cd ~/src
[remote]$ wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg
[remote]$ sh setuptools-0.6c11-py2.5.egg --prefix=$HOME
[remote]$ git clone git://eagain.net/gitosis.git
[remote]$ cd ~/src/gitosis/; export PATH=$HOME/bin:$PATH
[remote]$ python setup.py install --prefix=$HOME; cd
[remote]$ echo "export PYTHONPATH=$HOME/lib/python2.5/site-packages/" >> .bashrc
[remote]$ echo "export PYTHONPATH=$HOME/lib/python2.5/site-packages/" >> .bash_profile
[remote]$ echo "export PATH=$HOME/bin:$PATH" >> .bashrc
[remote]$ echo "export PATH=$HOME/bin:$PATH" >> .bash_profile
[remote]$ . ~/.bash_profile; gitosis-init < id_rsa.pub
[remote]$ chmod 750 $HOME/repositories/gitosis-admin.git/hooks/post-update

Using Gitosis

Now we can start using gitosis from our desktop

[local]$ mkdir ~/projects; cd ~/projects
[local]$ git clone ft_git@spicevan.com:gitosis-admin.git

The last command git clone ... deviates from the original instruction of: git clone ft_git@spicevan.com:gitosis-admin.git, because that command didn't work for me. So this is where the problems begin, and I'd love for someone else to figure out what is going wrong here...regardless, I'll continue since the above seemed to work okay for me.

Create your own repo

So now we want to create our own repository for our own projects so update the file: ~/projects/gitosis-admin/gitosis.conf on your local computer

[local]$ cat ~/projects/gitosis-admin/gitosis.conf

[group gitosis-admin]
writable = gitosis-admin
members = ftravers@ftravers-laptop

[group testgroup1]
writable = testrepo1
members = ftravers@ftravers-laptop


  • testgroup1 : is the name of the group
  • testrepo1 : is the name of the new repository
  • members : is a space delimeted list of users who can commit to this project

The members list should be the filenames from ~/projects/gitosis-admin/keydir folder without the .pub extension.

Push this up to the server:

[local]$ git commit -a -m"My comment."; git push

Now create the project on your local desktop...

[local]$ cd ~/projects; rm -rf testrepo1; mkdir testrepo1; cd testrepo1; git init
[local]$ git remote add origin ft_git@spicevan.com:testrepo1.git
# do some work, git add and commit files
[local]$ git push origin master:refs/heads/master