Neil Middleton

Deploying topic branches to Heroku

19 November, 2011

Deploying topic branches to Heroku

With Heroku it's super easy to create and deploy applications, almost to the point where hosted production applications are nothing more than a commodity.

Due to this, it's really easy to deploy your production environment, and then create sibling test environments for trying out various things such as deploys, load tests, or for deploying topic branches.

However, something worth noting is that Heroku ONLY deploy the master branch for a given git repository. So how do you manage this? Well, Git allows you to push one branch into another. For instance, lets say you want to push your staging branch onto Heroku's master branch of your staging application, which you've already setup. Simply run:

git push staging staging:master

This will push your staging changes into the Heroku master branch, and thus deploy it.

Now, if this is a common occurence you might want to shortcut this and make it happen by default. This can be done by telling Git to always push from one branch to another. For instance, for the same example as above.

git config remote.staging.push staging:master

replacing remote.staging.push with remote.your_remote.push and staging with your topic branch. Once you've done this, you can simply push to the appropriate remote:

git push staging

which will yield output confirming the branch has correctly deployed:

   16c73af..b1a78b4  staging -> master

I'm Neil Middleton.

I'm an engineer at Heroku based in the UK and the author of 'Heroku, Up & Running' for O'Reilly.

I'm a massive fan of keeping things simple, straight-forward and bullshit free.