I made acommit and pushed it to origin and heroku
Then I realised it was wrong, so I did
git reset --soft HEAD^
But when I'm pushing to Heroku Im getting
To [email protected]:app.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:app.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
I understand the problem. How should I proceed? How can I revert also last heroku commit? (I assume would be the best solution)
The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.
Also note that Heroku should not be considered a git hosting. It means that it's extremely uncommon to perform a git pull from Heroku. Instead, you should use a git hosting (such as GitHub or BitBucket) to store your repository and only perform push to Heroku to deploy the application.
Whenever you deploy code, change a config var, or modify your app's add-on resources, Heroku creates a new release and restarts your app. You can view your app's release history, and temporarily roll back to a previous release in the event of a bad deploy or config change.
The beginning of the range is exclusive, meaning it's not included. So if you want to revert the last 3 commits, you need to start the range from the parent of the 3rd commit, i.e. master~3 .
If you've reverted the commit locally you may need to git push
with a -f
option to force the commit in.
Also, you may want to have a look at Heroku releases which may help too.
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