Nick Zalutskiy Nick Zalutskiy - 2 months ago 7
Git Question

git equivalent for hg rollback

How would I "rollback" the last commit in git without deleting any changes?

This is something I've done often in hg:


  • Commit "Fixed 107."

  • Remembered that I forgot to do something

  • hg rollback

  • Do something

  • Commit "Fixed 107."


Answer

With git you may actually prefer to use the --amend option in that case.

  • Commit "Fixed 107."
  • Remembered that I forgot to do something
  • Do something
  • git commit --amend and edit the notes

If you need to rollback for other reasons take a look at git revert