Skip to content

Instantly share code, notes, and snippets.

@futzlarson
Created April 10, 2026 15:13
Show Gist options
  • Select an option

  • Save futzlarson/777cd98d4de4a47680d7f66745c43ead to your computer and use it in GitHub Desktop.

Select an option

Save futzlarson/777cd98d4de4a47680d7f66745c43ead to your computer and use it in GitHub Desktop.
Rebase vs Merge: when to use each

Rebase vs Merge: When to Use Each

What they do

Both solve the same problem: your feature branch is behind upstream and you want the latest code.

  • Rebase replays your commits on top of the latest upstream. No extra commits. Clean history.
  • Merge combines the two branches and creates a merge commit as a bookmark.

The only practical difference

Every time you sync with upstream:

  • Rebase adds 0 extra commits
  • Merge adds 1 merge commit

If you sync once before opening a PR, the difference is one commit. Doesn't matter which you use.

If you sync 5 times during a long-running branch, that's 5 merge commits cluttering your log vs none with rebase.

When to rebase

  • Your branch, your work, nobody else touching it
  • Short-lived feature branches
  • Right before opening a PR for a clean diff

When to merge

  • Shared branches (anything multiple people push to)
  • Long-lived branches like cm-qa, uat
  • When in doubt — merge is always the safe choice

Why merge is safer

Rebase rewrites history. If the branch has been pushed, you need git push --force after rebasing, which can blow away teammates' work. Merge never rewrites anything.

TL;DR

  • Solo branch? Rebase is fine.
  • Shared branch? Always merge.
  • Only syncing once before a PR? Doesn't matter, pick either.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment