Skip to content
BENIBIX Learn

Rebase

Development🔀 Version ControlBranches and History

Also known as Git Rebase

Your commits move to start from a newer point. The past reads as one line.

Think of it like

Think of it like moving your notes to the end of a list. Same notes, now after all the rest.

Example

Jack's search branch started before Emma's latest work. He rebases onto main, and his commit now comes after hers.

Why it matters

A straight history is easier to read and search. Many teams rebase before they merge.

Definition

A rebase moves your branch's commits so they start from a newer point. Git takes each of your commits and replays it on top of the other branch. The result is a straight line of history with no merge commit. Each moved commit gets a new code, because its starting point changed. That is why you should not rebase commits that others have already pulled.

Example code

console
$ git rebase main
Successfully rebased and updated refs/heads/search.
$ git log --oneline -2
85ece06 Add search
26b91bd Blue greeting
Jack's commit now sits on top of the newest commit on main.

Common mistake

Rebasing a branch others share. Their copies no longer match, and work can get lost or doubled.

Key takeaways

  1. 1
    Replay on top. Your commits move to a newer base.
  2. 2
    Straight line. No merge commit is made.
  3. 3
    Only your own. Never rebase what others pulled.

Compare

Learn it properly