Overview
Revert
Create a new commit that undoes the changes from a previous commit. This is the safest way to undo changes on shared branches.Options
Examples
Handling Conflicts
Reset
Move the current branch pointer to a different commit. This can also modify the staging area and working directory.Reset Modes
Revision Syntax
Examples
Recovering from Hard Reset
Cherry-pick
Apply changes from specific commits to the current branch.Options
Examples
Handling Conflicts
Use Cases
Backport a fix
Backport a fix
Extract commits from a branch
Extract commits from a branch
Rebase
Reapply commits on top of another base commit. This creates a linear history.Options
How Rebase Works
Examples
Comparison: When to Use What
Safety Tips
Create a backup first
Check reflog for recovery
Use wit undo
Don't rewrite shared history
Only rebase/reset commits that haven’t been pushed.
Related Commands
wit undo- Undo recent operationswit reflog- View history of HEAD changeswit amend- Modify the last commitwit uncommit- Undo last commit keeping changes staged