🎓 A1Learner
🔍
0 of 50 lessons completed

Merge or Rebase

Merge and rebase both join lines of work. They differ in what the history looks like afterwards.

A merged history

The shopping list join shows a diamond in the graph.

$ git log --graph --oneline --all

A rebased history

The oats work sits on a straight line. No merge snapshot marks its join.

$ git log --oneline --graph

Example

$ git log --graph --oneline --all

Key points

  • Merge keeps both lines visible in the graph.
  • The merge snapshot marks the join.
  • Rebase replays the work onto one straight line.
  • The straight line reads more simply.
  • Rebase rewrites hashes. Merge never rewrites.
  • Teams often merge shared work and rebase their own branches.
  • Neither is wrong. Pick the one your team uses.

Here, the history holds both shapes. The shopping list join shows a diamond. The oats work sits on a straight line.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which one rewrites hashes?