Git offers several ways to undo changes depending on the situation — discarding uncommitted changes, unstaging, amending the last commit, reverting a commit, or resetting. Knowing the right tool for each situation is important, valuable practical skill.
Undo uncommitted changes (working directory)
git restore <file> # discard unstaged changes to a file (revert to last commit)
git checkout -- <file> # older equivalent
git restore . # discard ALL unstaged changes (careful!)
git clean -fd
