Git reset can be hard, soft, or mixed

Finally, you will see what git reset --hard means, and what are the other reset options that we have.

To avoid messing up our repo again, go into a detached HEAD state, so at the end it will be easier to throw all the things away. To do this, checkout directly the penultimate commit on the master branch:

[32] ~/grocery (master)
$ git checkout HEAD~1
Note: checking out 'HEAD~1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the ...

Get Git Essentials - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.