Git Revert
Safely undo public commits by adding inverse commits.
- git revert
- undo pushed commit
- revert range
- revert abort
- safe undo
Git Revert
Safely undo public commits by adding inverse commits.
Commands
| Command | What it does |
|---|---|
git revert <commit> | Create an inverse commit (safe for shared history) |
git revert --no-commit <a>..<b> | Revert a range into the working tree first |
git revert --abort | Cancel a conflicted revert |
git log --oneline --grep=revert | Audit past reverts |
git push | Publish the revert like any commit |
Example
git revert a1b2c3d
git revert --no-commit v1.3.0..HEAD # review, then commit
FAQ
revert vs reset on main?
Revert adds history, so collaborators just pull; reset rewrites history and breaks everyone else's clone.
What if a revert conflicts?
Resolve like a merge, git add the files, then git revert --continue.
الأسئلة الشائعة
revert vs reset on main?
Revert adds history, so collaborators just pull; reset rewrites history and breaks everyone else's clone.
What if a revert conflicts?
Resolve like a merge, git add the files, then git revert --continue.
Git
Git Config Essentials
Set identity, defaults, and aliases for Git on a new machine.
Git Clone and Init
Start a repo from scratch or copy a remote repository locally.
Git Add and Commit
Stage changes and record them as commits with clear messages.
Git Branch Basics
Create, list, rename, and delete branches for parallel work.