Git on Dreamhost - selene tan
selene tan

Git on Dreamhost

by on Oct.14, 2009, under Blog

Though my website is hosted on Dreamhost, these days I mostly use them for version control hosting. So I was very happy when they set up git on their servers.

Casper Fabricius’ Keeping git repositories on Dreamhost using SSH has some instructions and a handy script for automating the process. Thing is, I tend to create the folders and files for a project before I set up the git repository. Casper’s script assumes you want to create the folder and repository at the same time.

So here’s my version of the script. If you call it without arguments, it assumes you want to make a repository for the current directory.
if [ $# -lt 1 ]; then
  mkdir $PROJECT_DIR
ssh $DREAMGIT_DOMAIN 'mkdir -p ~/git/'$PROJECT_DIR'.git && cd ~/git/'$PROJECT_DIR'.git && git --bare init'
git init
git remote add origin ssh://$DREAMGIT_DOMAIN/~/git/$PROJECT_DIR.git
touch .gitignore
git add .
git commit -m 'Created new repo'
git push origin master
echo "
[branch \"master\"]
remote = origin
merge = refs/heads/master" >>.git/config
echo "Your new git repo '$PROJECT_DIR' is ready and initialized at

Note: both Casper’s and my scripts still work if you call them with a directory that exists, e.g. dreamgit dir_that_exists. You’ll see mkdir spout an error, but the rest will execute.

:, ,

2 Comments for this entry

  • Clint

    Do you still use them for GIT? Just curious about the difference between doing this and using a service like GITHub.

  • selene

    I do! Mostly it’s for personal messing-around projects where I want to have a remote backup in case of emergency, but the code’s in no shape to be shown to the public. GitHub limits the number of private repositories you can have (free accounts don’t get any). GitHub has a lot more in the way of project management features, like issue tracking, and makes it easier to widely share your code. For small stuff I find it overkill.

    Another useful trick is to put your website files under version control and have the live copy be a checkout or export of the repository. You can even set up a server-side hook to immediately update or export the files on push. I used to do this before moving to a CMS.

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!