Revert Commits in Git
From the Git cheat sheet · Fixing Mistakes · verified Jul 2026
Revert Commits
Undo committed changes by creating new commits
bash
# Revert a commit (safe — creates an inverse commit)
git revert <commit>
git revert HEAD # Revert last commit
# Revert a range
git revert <oldest>..<newest>
# Revert a merge commit (-m 1 = keep first-parent line)
git revert -m 1 <merge-commit>
# Reset to a commit (⚠️ rewrites history)
git reset --hard <commit>💡 Revert is safe for public/shared branches
⚠️ Reset rewrites history — avoid on shared branches
✅ For lost commits, see the Reflog item below
📌 For applying specific commits, see Cherry-pick under Branching