Throw the Work Away

--hard is the same backwards move, but it keeps nothing. Staging area cleared, working directory cleared, changes gone.

This is the one git command that can genuinely lose work you never committed anywhere. It is also exactly what you want when an experiment went wrong and you just want to be rid of it.

Exercises

  1. Exercise 1. Same starting point as the last lesson, but this time get rid of the commit and its changes entirely.
  2. Exercise 2. A messier state: a commit to undo, something staged, and something unstaged. One hard reset clears all three — read the response carefully.
  3. Exercise 3. You know relative refs now, and this is where they earn their keep. Undo the last two commits without reading a single id off the graph.