how to undo all commits code example Example 1: remove the commit from local git reset --soft HEAD~1 Example 2: revert unpublished commits git reset --hard