git cancel changes in branch code example Example 1: git undo all changes git reset --hard Example 2: undo unstaged changes git git checkout -- .