To cancel a local Git commit, you can use the git reset
command. There are two common approaches:
- Soft reset (keep changes staged):
This undoes the commit but keeps the changes staged, allowing you to modify or re-commit them.
- Mixed reset (keep changes in working directory):
This undoes the commit and un-stages the changes, but keeps them in your working directory.
For a hard reset (discard changes completely), use:
This will remove both the commit and changes.