How to deploy Rails non master branch on Heroku

How to deploy Rails non master branch on Heroku

heroku rails non branch

No doubt Heroku is one of the best technology to quickly deploy web apps. In my case I am working on Rails 6 app and loves the way heroku takes care of all the dependencies with single command. After completing with code and i was ready for build. This time the branch name is demo (non master branch) therefore I ran git push heroku demo

$ git push heroku demo
counting objects ...
Pushed to non-master branch, skipping build.
To [email protected]:abc.git
* [new branch]      demo -> demo

You see, it skipped the build. The default configuration of heroku makes it build only master branch for every heroku push.

What if your master doesn’t have updated code which likely a very normal use case. In such case, you need to use the following command to push the non master branch to Heroku’s master branch.

$ git push heroku [branch_name]:master

This pushes your local test branch to the remote’s master branch (on Heroku).

When you are ready with master, merge that with heroku master with below command:

$ git push -f heroku master:master

Reference: Official documentation



Join my weekly digest to receive articles on how to explain things in interviews.

Leave a Reply