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