Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git revert last commit in heroku

Tags:

git

heroku

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)

like image 226
Martin Avatar asked Mar 09 '11 15:03

Martin


People also ask

How do I revert my last commit?

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.

Can I git pull from Heroku?

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.

Can you roll back to the latest version after going to a previous version of an app in Heroku?

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.

How do I revert a last 3 commit?

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 .


1 Answers

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.

like image 188
John Beynon Avatar answered Oct 21 '22 04:10

John Beynon