Compare

Git Merge vs Rebase

When to use merge, when to use rebase, and the tradeoffs between them.

Both commands combine histories, but they optimize for different outcomes. Merge preserves the true branch structure. Rebase rewrites history to keep it linear.

Use Merge When

You want to preserve the exact shape of collaboration history.

Your team prefers not to rewrite commits after they were shared.

Use Rebase When

You want a cleaner, linear branch before opening or merging a PR.

You are working locally and want to replay your commits on top of the latest main branch.

Rule of Thumb

Rebase your own local work. Merge shared history unless your team explicitly standardizes on rebasing.

Want the short version? Browse the compact sheet views and save the commands you use most into a Cheatbook.