Skip to content

What it is

Rebase replays commits onto a new base, rewriting their hashes; the result is a linear history instead of a merge bubble.

git rebase main in a feature branch does three things. First, it finds the common ancestor of the feature branch and main. Second, it stores the feature branch's commits from that ancestor. Third, it moves the feature branch onto main's tip and replays the stored commits one by one. Each replayed commit gets a new hash, a new parent, and possibly a resolved conflict.

The result is a linear history: as if the developer had written every commit after the latest main. Merge commits disappear. The history looks like main → f1 → f2 → f3, not main ↘ f1 → f2 → f3 ↗ with a merge bubble.