[Solved]-Should I use git to deploy websites?


I use git to track my website, and I deploy it like this:

git archive --format=tar --prefix="homepage/" master | gzip | ssh webserver "tar xvz -C ~/public_html"

This deserves a little explanation. The archive command for git will export the files for the master branch, which gets compressed with gzip to minimize network traffic. It’s received remotely over ssh, which is decompressed into the final destination directory.

The deploy script that I use has a little more going on, but this is the most important piece.


You can take a look at Fabric, popular among Djangonauts…


If the question is if you can you use git to deploy your django application, the answer is sure!

However, production deployment of a popular application can become complex – and go way beyond just rolling back files. You may need to run DB scripts (both upgrade and downgrade scripts), restart cron jobs, or move files around.

As part of your deployment process you may want to back up your code base in its entirety so that you can rollback any number of versions back.

One way to do this is with Capistrano which automates the entire deployment process for you. You author scripts in your development environment and issue commands like: cap deploy, cap deploy_with_migrations, cap rollback, etc. and everything is automated from the login all the way up to the backup process and running DB scripts. By having the deployment automated you eliminate errors in your production environment. I recently spoke to an organization who accidentally deleted their entire database while in the midst of a deployment and needed to restore everything from backups. Deployment errors can really break your business so you want to automate this if you are serious about it.

Though Capistrano is a Ruby-based deployment tool commonly used with Rails, it’s agnostic in terms of its automation capabilities. There are numerous posts on the Internet that discuss the benefits of deploying Django apps with Capistrano (google – django capistrano).

You can also check check out this link here



Well, I use SVN to deploy my website, so I’d say go for it! Keep in mind that you may have to restart/reload the server every time you update the code for the website (I’m not sure if Django or whatever you’re running it on is able to work around that).

Leave a comment