git revert

Undo a commit with a new commit

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

Applies the inverse of a commit — safe for shared branches.

Common flags
FlagMeaning
-nNo commit
-mMainline for merge commits
Examples
git revert HEADUndo the last commit safely · explain & risk-check →
Related
git reset
Open the full explainer →More in Git

Reference text is hand-written and may be incomplete — check man git for your version. Test destructive commands on a non-production system first.