20

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?

Community
  • 1
  • 1
Yarin
  • 173,523
  • 149
  • 402
  • 512

3 Answers3

20

It's a lot easier to achieve the desired result with heroku instead of the multi-step git process of checking in code, and pushing it. This keeps your git history clean.

$ heroku releases
$ heroku rollback v11
Ricky Sahu
  • 23,455
  • 4
  • 42
  • 32
  • Please add explanation as to why it's a better solution – StormeHawke Dec 17 '14 at 16:29
  • 2
    I think the question was, how to deploy a commit that has never been pushed to heroku remote before. You are giving solution on how to rollback to a commit that HAS been deployed to Heroku already – AzaFromKaza May 13 '15 at 07:25
19

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
matt
  • 78,533
  • 8
  • 163
  • 197
  • Awesome @matt- just what I needed. And I just found this described [in the heroku docs](https://devcenter.heroku.com/articles/multiple-environments#advanced-linking-local-branches-to-remote-apps) as well. Question: why would I need to `-f` force though? – Yarin Sep 29 '13 at 21:31
  • @Yarin If you’re trying to push an earlier commit than what is already on `master`, git will normally stop you. You need to use `-f` to say “yes I really mean to overwrite (and possibly lose) those later commits”. – matt Sep 29 '13 at 21:34
6

If you want to push a certain commit to heroku, it's done like so:

git push heroku 5ad0f3d913f2a92cc095af9c7b6242263da58160:master

Simply replace 5ad0f3d913f2a92cc095af9c7b6242263da58160 with your desired commit.

Source: https://stackoverflow.com/a/3230241/5783745

stevec
  • 41,291
  • 27
  • 223
  • 311