undo changes made to a file git code example Example 1: git delete changes git clean -df git checkout -- . Example 2: revert unstaged changes git git checkout -- .