Command Reference
git rebase Tutorial
Explains the core model of git rebase, recommended workflows, risks, and recovery options.
The short version
git rebase reapplies a set of commits onto a new base, so you often end up with similar content but different commit IDs.
When it is a good fit
- Bring a feature branch up to date with
main - Clean up commit history before merging
- Reorder, squash, or rewrite commits with interactive rebase
Basic workflow
git checkout feature/login
git fetch origin
git rebase origin/main
Handling conflicts
git status
# resolve conflicts manually
git add <resolved-files>
git rebase --continue
Abort if needed:
git rebase --abort
Why interactive rebase matters
git rebase -i HEAD~4
Interactive rebase is useful for:
- squashing noisy commits
- reordering history for readability
- rewriting commit messages
- dropping experimental commits