how to undo hard reset git code example Example 1: git reset hard git reset --hard Example 2: undo git reset HEAD~1 git reset HEAD@{1}