Core Git 7/8

Merge And Rebase

Both commands integrate change. Merge preserves branch topology and keeps the original context of how work came together, while rebase rewrites commit lineage and creates new commit IDs. Team policy matters because rebasing shared branches changes published history.

Back to Git Concepts overview

Integration Choices

feature branch ready run checks + review merge or rebase strategy protect shared history

Merge Path (Topology Preserved)

PR approved main
git switch main && git pull --ff-only origin main
git merge --no-ff feature/payments

Rebase Path (Linearized Branch)

Before rebase replay commits After rebase f1' f2' Rebase rewrites commit IDs. Use on your branch before merge; avoid rewriting protected shared history.
git fetch origin
git rebase origin/main
git push --force-with-lease (only if policy allows)

Decision Rule Of Thumb

Use Merge when: branch is reviewed by PR history context should stay visible team prefers audit-friendly topology Use Rebase when: cleaning your local feature branch updating to latest main before PR merge history rewrite is team-approved
Previous Undo + Recovery All Concepts Back To Overview Next Collaboration + DevOps