git command to undo all changes code example Example 1: git discard staged changes git reset HEAD git checkout . Example 2: how to undo git clean -fd command git clean -fdx