discard commit in git code example Example 1: git revert last commit unpushed git reset --soft HEAD~1 Example 2: git clear commits git reset --hard origin