The Golden Middle Path - a blog by Amit K Mathur

Git and Rails - deploy from a branch

If you have Capistrano configured to deploy your Rails project, and you want to deploy from a branch, in deploy.rb, set the branch this way:

set :branch, $1 if `git branch` =~ /\* (\S+)\s/m

With this change, Capistrano will deploy whatever branch you are currently in rather than the default master.

In order to quickly glance at what branch you have currently deployed to the server, display the branch in your web application’s footer. Add the following to the layout:

 <%= `git log -n 1 --format=format:'%d%C(reset)'`.split[1].match(/^(.*?)[,\)]/)[1] %>
Share:

Post a comment


(Formatting help)