undo changes git command line code example Example 1: git reset one file git checkout HEAD -- my-file.txt Example 2: revert unstaged changes git git checkout -- .