Overview
Git provides several undo-related commands because "undo" can mean different things. You may want to unstage a change, discard an uncommitted edit, recover a deleted file, remove a tracked file, undo the latest commit, or reverse an older commit without erasing history.
The correct command depends on what must change and what must remain.