🔀 CHAPTER 7 · GIT REBASE
Chef You

Rewrite the
Recipe Timeline

Merge keeps history messy. Rebase rewrites it — replaying your commits on top of the latest changes as if they happened in a clean, straight line.

Scene I

The tangled timeline

Chef You

You branched off to add icing. Meanwhile, main got 2 new commits. Now your branch is behind and the history looks like a spider web.

With git merge, you get a merge commit — an extra knot in the timeline.

With git rebase, you replay your commits on top of main — as if you started fresh. Clean, linear history.

📜 REBASE OPERATION See the tangled timeline, then rebase
❌ BEFORE REBASE (tangled)
Rebased!

🎉 Clean timeline achieved

Your commits now sit neatly on top of main — no merge commits, no spider-web graph. Just a straight, understandable line.

But remember:

⚠️ GOLDEN RULE
Never rebase commits that have been pushed publicly. Rebase rewrites history — if others are building on those commits, their timelines will break.
$ git checkout feature/icing
$ git rebase main
Applying: Add icing base recipe
Applying: Add decoration guide
✓ Successfully rebased onto main
Epilogue
Rebase is time-travel editing.
Clean history is worth it.
But never rewrite shared history.
git merge
Preserves history
Creates merge commits
vs
git rebase
Rewrites history
Linear, clean timeline