Ghopper21 Ghopper21 - 13 days ago 6
Git Question

How to push your local master branch to Heroku when you've already pushed a feature branch?

To try out a feature branch, I pushed it to Heroku's master (since that's the only branch it uses for your website), i.e. I did:

git push heroku feature-foo:master


Meanwhile, I made some commits to my local master branch. Now I want to push my local master back out to Heroku, but am getting:

To git@heroku.com:foo-repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:foo-repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


This makes sense, because indeed Heroku's master is really on my feature-foo branch and thus is ahead of master. But I don't want to pull and merge from Heroku -- because that would be the same as merging my feature-foo branch, which I don't want to do. Right now, I just want to push my local master without the feature-foo commits. (Indeed I have already used
heroku rollback
so that the feature-foo changes aren't live on the site.)

How do I do that?

Answer

The answer turns out to be simple. Do a forced push, i.e.

git push -f heroku master
Comments