delete last commits git code example Example 1: git cancel last commit Click to copygit reset --soft HEAD~1 Example 2: revert last commit Click to copy$ git reset --soft HEAD~1