delete a commit before pushed code example Example 1: cancel a commit not pushed git reset --soft HEAD~ Example 2: git delete last commit in remote $git rebase -i HEAD~2