Author:
Cancel Commit⚓︎
This guide helps you cancel your last Git commit.
Remove Commit but Keep Changes⚓︎
If you want to cancel your last commit but keep the changes:
HEAD~1refers to the commit before the last one.--softoption keeps your changes in the staging area.
Remove Commit and discard Changes⚓︎
--hardoption discards all changes in the working directory and staging area.
Remove Commit but Keep Changes in Working Directory⚓︎
- By default, it is
--mixedwhich unstages changes but keeps them in the working directory. Theoretically, it resets the index toHEADand does not affect the working tree.
Command line resource: Git Reset Documentation