Modern QA2026Rebase — tiles
Log inJoin
11 / 57 · 17 Git & Version Control · Rebase vs Merge← prev⊞ allnext →☰ Read as one page

2.3Rebase

A rebase replays your commits on top of the target branch, creating a linear history as if you had written your code after the latest changes on the target.

git checkout feature/login-tests
git rebase main
# Your commits are rewritten on top of main's HEAD

What the history looks like after rebase:

Before rebase:
main:    A --- B --- C
                \
feature:         D --- E

After rebase:
main:    A --- B --- C
                      \
feature:               D' --- E'  (new commits with same changes)

The commits D and E are replaced by D' and E' -- same changes, but new commit hashes. The history is linear.

Advantages of Rebase

  • Clean, linear history: No merge commits cluttering the log
  • Easier to review: PR diffs show only the feature changes, not merge noise
  • Simpler bisect: git bisect works more reliably on linear history

Disadvantages of Rebase

  • Rewrites history: Commits get new hashes, which is dangerous for shared branches
  • Can be confusing: If you rebase incorrectly, you may lose work
  • Conflict resolution is per-commit: You may need to resolve the same conflict multiple times if several commits touch the same file