0

I can't believe I'm the first one to ask this, but my searching through git questions hasn't given me the precise answer I need, so: I just made a commit on the master branch and I realize that it is buggy and won't be ready for prime time without alot of work, so I just want to get rid of it. How do I do this? git reset --hard HEAD and git reset --hard sha-of-bad-commit don't do anything except move the HEAD back to this bad commit.

bob.sacamento
  • 6,283
  • 10
  • 56
  • 115
  • Possible duplicate of [How to undo last commit(s) in Git?](http://stackoverflow.com/questions/927358/how-to-undo-last-commits-in-git) – Andrew C Jan 12 '17 at 19:51

1 Answers1

1

You need to target the commit before the wrong commit.

git reset --hard HEAD~
Axnyff
  • 9,213
  • 4
  • 33
  • 37
  • Thank you! That did it. stack-o is not letting me accept your answer yet. If I don't get around to it later, please feel free to remind me. – bob.sacamento Jan 12 '17 at 19:28
  • Or '--medium' or '--soft' if you don't want to loose the work you did in the workspace. – Philippe Jan 12 '17 at 19:31
  • @Philippe: `--mixed` not `--medium` :-) it's also the default if you don't specify one of `--soft`, `--mixed`, `--hard`. Also, now you have me doing it, I almost typed soft/medium/hard. :-) (It would make sense!) – torek Jan 12 '17 at 20:19