Deploying on Dreamhost using Git
I’ve had to this multiple times for multiple projects and thankfully I had written down the instructions when I first did it in a .txt file. Before I lose those instructions, I wanted to jot those down here.
As a side note, I find this to be extremely useful. You get versioning control and you can easily make small changes and perform updates to a site via the command line, without needing to go through the entire FTP login process. It is especially faster if you save the SSH key. That way you don’t have to enter your password everytime you push your code.
Here are the step-by-step instructions assuming the project name to be ‘rainbows’:
-
Update the robots.txt:
User-agent: * Disallow: /relative-path-to-rainbows
- If your site uses a database, create the database and other dependencies on the server.
-
Login via SSH on server: username@domain.com. Navigate to where you want to deploy your website. Execute the following:
mkdir rainbows cd rainbows git init git config receive.denyCurrentBranch ignore vim .git/hooks/post-update # paste this script: http://utsl.gen.nz/git/post-update chmod +x .git/hooks/post-update
-
In your local repository, add the remote for the live site:
git remote add live ssh://username@domain.com/path-to-rainbows
-
In local copy, push to remote repository:
git push live master # On the remote repository, you may or may not need to # do 'git checkout master' to see the changes.
-
That’s it! Whenever you need to push code, just do:
git push live
- To make the process a lot faster, set up SSH Keys to avoid having to enter the password everytime. Instructions for that coming up later.
Reference:
http://stackoverflow.com/questions/279169/deploy-php-using-git
I have added to my local config file the remote for live site by – git remote add live ssh://username@domain.com/path-to-rainbow. In my case, the ‘path-to-rainbow’ looks something like ‘/home/madhavi/mydomain.com’. Yes, the directory is named “mydomain.com”
When I try to ‘git push live master’, I get an error – ‘fatal: bad config file line 12 in .git/config’. Any ideas on how I can resolve this?
Thanks!