Pushing to Dreamhost using Git
I've been using Dreamhost.com for several years, hosting a few sites.
I've since used Heroku, and I've grown accustomed to being able to deploy code using Git. git push heroku master became a convenience I rely upon.
I wanted to be able to push to Dreamhost using Git. I was able to accomplish it by 1) creating a folder to push to, and 2) modifying the hooks/post-receive file in the .git folder on my Dreamhost account to deploy the site after pushing.
Create a folder to push to
Create a place to push your Git repo to in Dreamhost. For example, I created the folder ryanwold.com.git for the website ryanwold.com.
// on a Dreamhost VPS server
ryanwold.com # where the Rails app lives
ryanwold.com.git # the Git destination to push to
Modify hooks/post-receive to deploy after being pushed to
// in hooks/post-receive file, add:
#!/bin/sh
git --work-tree=/home/username/site.com --git-dir=/home/username/site.com.git checkout -f
cd /home/username/site.com
bundle install
touch tmp/restart.txt
By Ryan Wold · © 2013–2026 Ryan Wold
Licensed CC BY-NC 4.0. AI training requires a license — machine-readable terms.
Tip: $afomi on HandCash · afomi@handcash.io