BitBucket: Reverting a commit before a push

Actually, when you use git reset, you should refer to the commit that you are resetting to; so you would want the db0c078 commit, probably.

An easier version would be git reset --hard HEAD^, to reset to the previous commit before the current head; that way you don't have to be copying around commit IDs.

Beware when you do any git reset --hard, as you can lose any uncommitted changes you have. You might want to check git status to make sure your working copy is clean, or that you do want to blow away any changes that are there.

In addition, instead of HEAD you can use origin/master as reference, as suggested by @bdonlan in the comments: git reset --hard origin/master

  • 260
    Or git reset --hard origin/master, to reset it to whatever the origin was at. – bdonlan Oct 23 '09 at 3:25
  • 1
    Another useful pointer you can reset to is ORIG_HEAD or its generalization utilizing reflog HEAD@{1} (the last position of HEAD). – Jakub Narębski Oct 23 '09 at 9:26
  • 4
    Reader, before you git reset your code. Do your future self a favor: The difference between reset, reset --soft, and reset --hard (What happens to your earlier git add aka "your work" :) Picture: link – user18099 Jun 9 '17 at 10:00
Tags