Pushing testing branches to Heroku

I really love using heroku for my rails applications. It provides me easy deployments, easy access to a host of add-ons, but mostly the fact that I can use the free plans to test/develop. I often find that for small projects I will start developing and push to heroku after I have something significant to deploy. I will then continue to test/develop locally and only push new big features as they are completed.

The problem with this is when you start developing multiple seperate feature branches and a client needs to remotely view the individual branches to review changes at different times. So how do you solve this? The problem is that heroku only deploys the master branch of any git repository.

The solution is quite simple, first create a seperate heroku app, but this time instead of running

git push heroku-staging master

we are going to push our feature branch to the master branch of the heroku app

git push heroku-staging feature-branch:master

This will deploy our feature branch as the master branch on the heroku app. To push another branch in the future we repeat the above with the ‘-f’ flag

git push -f heroku-staging feature2-branch:master