git how to reset one file code example Example 1: git undo all changes git reset --hard Example 2: git file reset to head git checkout HEAD -- my-file.txt