Git repositories on Dreamhost via SSH

After some mucking around, I managed to create a remote repository for Git projects on my Dreamhost account, without the need of WebDav. Here are the steps:

  1. First, you’ll need to install Git on the server side. But git also requires Curl, so the first step is compiling Curl.
    Get curl here and Git here.

  2. Install Curl using the default process of ./configure && make && make install. Just remember that you are working on your own home directory, so you’ll need to run ./configure with a --prefix like $HOME/software or something (just a suggestion, thought. But the prefix must be somewhere in your home directory.
  3. Now, to install Git, you need to configure it with ./configure --with-curl --includedir=$HOME/software/include/. Why? Because your curl headers are in $HOME/software and, without that, Git won’t compile with Curl and SSL (required for SSH). After the configure, you need to run make NO_MMAP=1 (as pointed by the Dreamhost Wiki, I haven’t tried without it but there they say it makes bad things like rape small children or kill Git processes or something.). Once it finishes compiling, install it with make NO_MMPAP=1 install (again, I’m not sure if the NO_MMAP=1 flag is required here, but I used it just to be sure.)
  4. Next step is to make Git accessible. Edit your .bash_profile and add $HOME/software/bin to your PATH. Note that changing it on your .bashrc doesn’t work — You have to add it on your .bash_profile. You’ll probably want to disconnect and connect again just to be sure that it will work (call git after logging again; if it complains about unknown command, your PATH is not right.)
  5. Almost done with the server side. Now you need to create the repository for your projects. Putting it into your “host directory” (the directory with your webpage) will make it easier to someone clone it. So go there and mkdir project && cd project && git --bare init-db. That will create a bunch of directories needed by Git.

Now you’re done with the server side. This step assumes that you already have a local Git repository (e.g., you did a git init and committed at least one revision on it.) On your computer you’ll need to change your Git config inside your project to have the following:

[remote "hostname"]
    url = ssh://
	fetch = +refs/heads/*:refs/remotes/dreamhost/*
	push = refs/heads/*

Just be sure to change username to your Dreamhost username (twice in that row), server to the Dreamhost server you are allocated (or you can replace the whole thing with your own hostname, but you’ll still need to put it on the path), hostname is your hostname directory and project is the name of the project you created in the server. Once you updated your config, do:

  • git-update-server-info
  • git push hostname master

It should work at this point. Note that I have changed my SSH to be passwordless, so you may find an issue if you don’t.