Ankit Ahuja

Deploying on Dreamhost Using Git

I’ve done this for multiple sites (including a Wordpress blog) and thankfully I wrote down the instructions when I did it the first time. I find this way to deploy really useful. It gives you version control, and an easy and quick way to deploy small, incremental changes. Deploying is as simple as executing git push live from the command line.

Here are the step-by-step instructions to follow assuming the site name to be rainbow:

  • Add or update the robots.txt in the containing folder of rainbow
    User-agent: * Disallow: /relative-path-to-rainbow

  • To avoid entering your password every time, copy your SSH public key to the server using ssh-copy-id. On Mac, you can install ssh-copy-id using homebrew

    brew install ssh-copy-id

  • Make sure you have local SSH keys setup. Then, do

    ssh-copy-id -i

  • SSH into the server


  • Navigate to where you want to deploy your site on the server. Then, do

mkdir rainbow
cd rainbow
git init
git config receive.denyCurrentBranch ignore   
curl > .git/hooks/post-upda
chmod +x .git/hooks/post-update   
  • In your local repository, add the remote (say live) pointing to the repository on the server:

    git remote add live ssh://

  • In your local copy, push to the remote repository

    git push live master

  • On the remote repository, you may need to do git checkout master the first time to see the changes.

  • That’s it! Whenever you need to deploy, just do

    git push live