12 / 57 · 17 Git & Version Control · Rebase vs Merge← prev⊞ allnext →☰ Read as one page
2.4When to Use Each
| Situation | Use | Reason |
|---|---|---|
| Updating your feature branch with latest main | Rebase | Keeps your PR clean and easy to review |
| Merging a PR into main | Merge (or squash merge) | The merge commit marks the integration point |
| Integrating a long-lived branch | Merge | Preserves the complete history of the effort |
| Shared branch with multiple contributors | Merge | Never rebase commits others have based work on |
| Cleaning up commits before opening a PR | Interactive rebase | Combine WIP commits into logical, reviewable units |
The golden rule: Never rebase commits that have been pushed to a shared branch and that others may have based work on. Rewriting shared history causes conflicts for everyone who has pulled those commits.