Line At A Time
Level 2: Rebase: A Straight Line
Rebase: A Straight Line Replay your branch on top of main, then fast-forward: no merge commit.

A merge commit is an honest record of two histories joining, but some teams prefer their history as one straight line with no knots. The tool for that is git rebase: it lifts your branch's commits off and replays fresh copies of them on top of another branch.

The flow, starting on your feature branch: git rebase main replays your work on top of main's latest commit. Then switch to main and merge; because your branch is now simply ahead, the merge fast-forwards. No merge commit; the line stays straight.

Two things to know. Merge commits vs a linear history is a stylistic choice; teams pick one and stay consistent. And one golden rule: only rebase commits you haven't shared yet. A rebase replaces commits with copies, which confuses anyone who already has the originals. (Real git quietly keeps the originals for a while in case you regret it; this sandbox tidies them away.)

git rebase <name>Replays your branch's commits on top of that branch.
git switch mainGet back onto main so it can receive the work.
git merge <name>Now just a fast-forward: history stays a straight line.
Your task

Replay your branch on top of main, then fast-forward: no merge commit.

Open this level in your browser to type the commands at a live git prompt with an animated commit graph.