how to reverse a git reset HEAD~1 code example Example 1: git reset head sudo git reset --hard Head Example 2: undo git reset HEAD~1 git reset HEAD@{1}