[email protected] ~/notes>


Hosting Your GIT Repository on DreamHost

A few weeks ago I needed a private remote Git repository.
Since I already have a DreamHost account, I didn’t want to pay for GitHub just to be able to set my repository as private.

DreamHost does not officially support Git on their Web Panel, so you must set things up manually.

There is a Git entry on their Wiki but it looked a bit messy, so I decided to write a cleaner tutorial.

Keep in mind that I’m using WebDAV.
It allows more than one user to push to the same repository, but it’s also slower.

You can use SSH but it’s a lot more complex to setup.
If that’s what you want, read the DreamHost Wiki.

Setup a WebDAV folder

Login to DreamHost Web Panel
Go to Goodies –> Htaccess/WebDAV
Select the domain name you want to use
Click “Set Up A New Directory”

DH Panel/WebDAV

Create the remote repository

Git cannot create the remote repository, it only operates on existing ones, so we need to create an empty repository locally and manually upload it to DreamHost.

So, there we go, open a console and..

[email protected]:~/dev$ mkdir blank.git
[email protected]:~/dev$ cd blank.git/
[email protected]:~/dev/blank.git$ git --bare init
Initialized empty Git repository in /home/carlos/dev/blank.git/
[email protected]:~/dev/blank.git$ touch git-daemon-export-ok
[email protected]:~/dev/blank.git$ git --bare update-server-info
[email protected]:~/dev/blank.git$ mv hooks/post-update.sample hooks/post-update
[email protected]:~/dev/blank.git$

Upload the blank repository and rename it

Use Nautilus or any other file manager that supports WebDAV to upload blank.git to Dreamhost and rename it to something meaningful. For the purpose of this example, let’s call it project.git

On Ubuntu:


After it finishes uploading, rename the folder from blank.git to project.git

When I renamed the file, I got an error message saying it failed, but refreshing showed it actually worked.


If you’re starting fresh and all you need is a blank repository, then you’re set.
Just clone your repository and start working!

[email protected]:~/dev$ git clone http:[email protected]/git/project.git
Initialized empty Git repository in /home/carlos/dev/project/.git/
warning: You appear to have cloned an empty repository.

[email protected]:~/dev$ cd project
[email protected]:~/dev/project$ (work, work, work)
[email protected]:~/dev/project$ git add README
[email protected]:~/dev/project$ git commit -m "your commit message"
[master (root-commit) 5bbe5f6] your commit message
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
[email protected]:~/dev/project$ git push origin master
Fetching remote heads...
updating 'refs/heads/master'
from 0000000000000000000000000000000000000000
to 5bbe5f6507fa39293bdc9674ca4ae2e0a1d2f15e
sending 3 objects
Updating remote server info

[email protected]:~/dev/project$ git pull
From http:[email protected]/git/project
* [new branch] master -> origin/master
Already up-to-date.
[email protected]:~/dev/project (master)$

Optional: Push your project repository to DreamHost

Otherwise, if you already have a project repository that you’ve been working locally, now is the time to push it to DreamHost.

Instead of cloning the new repository, push your project there first:

[email protected]:~/dev$ cd real_project/
[email protected]:~/dev/real_project$ git config remote.upload.url http:[email protected]/git/project.git/

  # It is important to put the last '/'; Without it, the server will send a redirect which git-http-push
  # does not (yet) understand, and git-http-push will repeat the request infinitely.

[email protected]:~/dev/real_project$ git push upload master
Fetching remote heads...
updating 'refs/heads/master'
from 0000000000000000000000000000000000000000
to a10703d8e400ca9df1b19345975718935c083905
sending 107 objects
Updating remote server info
[email protected]:~/dev/real_project$

Then confirm it worked and start fresh by cloning it.

[email protected]:~/dev/real_project$ cd ..
[email protected]:~/dev$ git clone http:[email protected]/git/project.git/
Initialized empty Git repository in /home/carlos/dev/project/.git/
got a10703d8e400ca9df1b19345975718935c083905
walk a10703d8e400ca9df1b19345975718935c083905
got 574596c4cc435461515aa1a4c3cdd0e93af947f3
got 067f993be7432ac27e8a6e9636dea53dcc3d8632
got 475be0881778acd2de7404175fa323823e4d1ac0
walk 067f993be7432ac27e8a6e9636dea53dcc3d8632
got b7b5d32db9dd30c9ea28434b125781eb4a3e95b2

[email protected]:~/dev$ cd project/
[email protected]:~/dev/project$ git log --oneline
a10703d Adds a beautiful whitespace! :)
067f993 Adds project description.. or sort of
80c2e22 removes rerun.txt
07e3cd2 Initial commit

[email protected]:~/dev/project$ git pull
Already up-to-date.

[email protected]:~/dev/project$ git push origin master
Fetching remote heads...
'refs/heads/master': up-to-date
[email protected]:~/dev/project$

And you’re good to resume working on your project :)

Bonus: saving your WebDAV password

Now, if you’re thinking that typing the WebDAV password over and over again kind of suck, you can save it so that git won’t ask you anymore.

[email protected]:~/dev$ echo "machine www.example.com login bob password secret" >> ~/.netrc

There is only one thing to keep in mind. When you save your password like this, you need to drop the bob@ from the urls.
So, instead of referring to your repository as http:[email protected]/git/project.git/ you need to use just http://www.example.com/git/project.git/
If you do this after you finished everything and cloned your repository, then git will have already saved the “wrong” url into its config file and will keep asking you for the password.

To fix this you can either clone again using the correct url or fix git’s config manually by doing:

[email protected]:~/dev/project$ git config remote.origin.url http://www.example.com/git/project.git/
[email protected]:~/dev/project$

Now, just for reference :)

[email protected]:~/dev$ more /etc/issue.net
Ubuntu 9.10
[email protected]:~/dev$ git --version
git version
[email protected]:~/dev$ date
Thu Feb 25 08:55:18 BRT 2010
[email protected]:~/dev$