Revert a Commit (Safe Undo)
Git · Undoing Changessyntax
git revert <commit>example
git revert a1b2c3d
git revert HEADoutput
[main g7h8i9j] Revert "Add user authentication endpoint"
2 files changed, 3 deletions(-), 45 insertions(-)Note Revert creates a NEW commit that undoes the changes from the specified commit. Unlike reset, it doesn't rewrite history, making it safe for shared/public branches. Always prefer revert over reset for pushed commits.