Search code examples
githeroku

How can I deploy old commits to Heroku


We're trying to deploy a big Rails project to Heroku for the first time, but something's breaking during the Heroku compilation process and we have no way of knowing what.

So now we're going to plan B, which is to walk up the commit chain and test deploy each step of the way against Heroku until we figure out at which point it becomes un-compileable. (Yea, it's the best I could come up with at this point.)

So I figured I'd just clone the project locally, checkout some old commits, and push to heroku. But then I discovered that if I push to heroku from anything but master, it doesn't build the app?? Instead it says: "Pushed to non-master branch, skipping build."

So now even my bad plan is a non-starter. I'm just looking for a break here. Any ideas on how to do what im trying to do?


Solution

  • It’s not that Heroku only builds if you push from master, rather Heroku will only build if you push to master. If you just do

    git push heroku
    

    then you are probably pushing your local branch to one with the same name on Heroku (the exact default behaviour is configurable). You can push from a different local branch to Heroku master with

    git push heroku my_local_branch:master
    

    or, if you are already checked out on my_local_branch you could use

    git push heroku HEAD:master
    

    See the documentation for git push – the examples towards the end in particular may help.

    You will probably also need to use -f to force the push:

    git push -f heroku my_local_branch:master