githerokugithub

Git, how to go back?


I did these operation:

$ bundle exec rspec spec/
$ git add .
$ git commit -m "Finished layout and routes"
$ git checkout master
$ git merge filling-in-layout
$ git push 
$ git push heroku

But then I found the program messed up. I want to go back to last commit. Both local and GitHub and Heroku. How can I do this?


Solution

  • In all of your branch, type

    git reset --hard HEAD^
    

    this will reset and discard all the changes to the last commit.

    if you don't want to discard your changes in wrong commit, you can use

    git reset --mixed HEAD^