Reputation: 3638
I'm using Heroku and have a Rails app that is stable (production env), so I wanted to create something new where I can have quality assurance env where I can see how the changes will work on Heroku (as well as aggregating enhancements for releases) without always pushing to my production app.
So what I did was create a new Heroku app, and also create a new branch locally (dev). My intention was to merge dev into master locally after I tested the change on my new Heroku QA app, and then push to Heroku production from my master branch.
My approach might be a bad one with my landscape, I'm a newbie, so this was just my best guess at how to do this.
But when I pushed my dev branch to my new QA app, it worked for pushing to a dev branch of the QA app, but not the master. So I couldn't see (and test) my changes on the new QA app. It seems to be telling me that I can only push the master branch to the master of my QA app, since I pulled already and everything was already up-to-date, but I receive this error:
Pushing to [email protected]:foobar/QA.git
To [email protected]:foobar/QA.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:foobar/QA.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.
Can someone please help me figure out what I'm doing wrong - either with my environments or with Git? Thank you.
Upvotes: 17
Views: 12096
Reputation: 4287
Use the following command to push the update forcefully git push -f heroku master
Upvotes: 2
Reputation: 12643
Heroku apps only run off of the master branch of the app repository (local to Heroku). If you want to deploy a branch to Heroku which isn't the master branch of your local repo, then you need to specify it. In your case it would be something like git push qa-remote dev:master
(replace qa-remote with the actual name of the remote to your QA app), which says push my local dev branch to the master branch on qa-remote.
When you push like that for the first time, you'll likely need to add the -f
flag to force push (non-fast-forward). Subsequently you should be able to push without the -f
flag, as long as your local branch is up-to-date.
Upvotes: 29
Reputation: 4570
Try pushing with the -ff
(fast-forward) option: git push heroku master -ff
(replace heroku
with the actual name of heroku remote).
Upvotes: 43