Git merge vs rebase: what is the difference?
GitHub explains the practical difference between git merge and git rebase, focusing on how each approach affects branch integration and commit history.
Overview
What git merge does
- Used to bring branches together (commonly in team workflows).
- Preserves the exact story of how the code came together by keeping the branch structure in history.
What git rebase does
- Used to clean up a personal branch by building work directly on top of the latest updates.
- Helps keep commit history cleaner (more linear) by replaying commits onto a new base.
When to use which (high level)
- Merge: good for integrating team branches while preserving how work was combined.
- Rebase: good for updating and tidying up a personal branch before it’s integrated.