delete git pushed commit code example Example 1: cancel a commit not pushed git reset --soft HEAD~ Example 2: remove commit not pushed git reset --hard origin/main