Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

heroku

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 [email protected]:foo-repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]: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?

like image 845
Ghopper21 Avatar asked Apr 08 '13 16:04

Ghopper21


People also ask

How do I push a feature branch to Heroku?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.


1 Answers

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

git push -f heroku master
like image 78
Ghopper21 Avatar answered Oct 06 '22 01:10

Ghopper21