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?
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.
The answer turns out to be simple. Do a forced push, i.e.
git push -f heroku master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With