git revert last commit on branch code example Example 1: revert git commit git revert <the_commit_hash> Example 2: git undo last commit git reset --soft HEAD~1