Hosting a Git repository on a Hetzner managed server

Installing Git on a Hetzner managed server is a piece of cake

[2010-12-09]

Unlike Bazaar, Git needs to be installed on a machine that hosts a repository. But this isn't a big deal. If installed by an ordinary user, it will place its binaries in ~/bin/

I'll call the Hetzner box "hetz" and your desktop "desktop" in your command prompt, so you can see where you're logged in. On your Hetzner box, create some handy directories, if you haven't already, and download and compile the source, like so:

hetz$ mkdir ~/git ~/bin ~/src ; cd ~/src
hetz$ wget http://kernel.org/pub/software/scm/git/git-1.7.3.3.tar.bz2
hetz$ tar -xjf git-1.7.3.3.tar.bz2
hetz$ cd git-1.7.3.3
hetz$ make NO_CURL=YesPlease
hetz$ make NO_CURL=YesPlease install

That's it. Now let's say you have a Git repository on your desktop in the ~/proj directory (like in the manual) ...

desktop$ git clone --bare ~/proj proj.git
desktop$ touch proj.git/git-daemon-export-ok
desktop$ scp -r proj.git myuser@hetznerbox.co.za/usr/home/myuser/git/

Now you're set. Push changes up with

desktop$ git push --receive-pack=~/bin/git-receive-pack ssh://myuser@hetznerbox.co.za/usr/home/myuser/git/proj.git

Pull changes down with

desktop$ git pull --upload-pack=~/bin/git-upload-pack ssh://myuser@hetznerbox.co.za/usr/home/myuser/git/proj.git

(You need to specify the path to git-receive-pack and git-upload-pack because Hetzner managed servers' SSH configuration does not allow SSH clients to set the path. To same myself the hassle of typing all that, I just script them in ~/bin/git-push-he and ~/bin/git-pull-he.)