- Creates a new "merge commit" that combines changes from both branches
- Preserves the full history and original branch structure
- Non-destructive operation (doesn't change existing commits)
- Moves your branch's commits to start from the tip of the target branch
- Creates a linear, cleaner history by reapplying your commits one by one
- Rewrites commit history (changes commit hashes)
Use merge when:
- Working on a shared/public branch that others are using
- You want to preserve the complete history
- You need to maintain merge context
Use rebase when:
- Working on a personal/feature branch
- You want a cleaner, linear history
- You want to avoid "merge bubbles" in the graph
For updating your feature branch (feature/navigation-section
) from another branch (like main
):
# If you want a clean history (recommended for feature branches)
git checkout feature/navigation-section
git rebase main
# If others are also working on your feature branch
git checkout feature/navigation-section
git merge main
Rebase is generally preferred for feature branches as it creates a cleaner history.