Using Git for simple deployment
Websites
Wednesday, 02 June 2010 21:03

Setting up a deployment process for small projects isn't a huge challenge. You just copy the files out and you're done, right? Well, time and time again I have found that it's actually really nice to have a consistent deployment process even for small projects so that you don't have to think when you are deploying. You just hit "go" and you can trust that it will work. However, since I'm talking about small, simple projects, it's not worth the time to develop anything elaborate. We need something really simple.

I have been using git for this purpose and have loved it. If you don't know what git is, you can learn more at the git website. This advice would probably apply just as well to Mercurial. I wouldn't suggest it as much for use with Subversion or CVS though. Deploying your code using git is dead simple. All you have to do is clone your git repository on your production server. Then, choose a branch that you will keep stable. You might use the standard master branch or you might create one called production. Whichever you choose, keep this branch very stable. When you're working on a feature, all you have to do is merge the code into this branch, login to your production server and do a git pull. You might also need to restart apache or something like that of course.

This setup requires that you don't have anything in your repository that is specific to a deployment environment. You need to be able to configure things like database passwords in a config file that is not tracked by git. This is something you should do anyway, so don't complain.


blog comments powered by Disqus