layman/terms
Git words

Rebase

ree · base

In shortPicking up the commits on your branch and replaying them on top of the latest main version, as if you'd started from there.

While you worked on your branch, the main version moved on. Rebasing lifts your work up and sets it down again on top of the newest version.

Picture a long string across a wall with instant photos clipped along it, one for each step of a project. That’s the main history. A while back you started a short side string of your own photos. Since then, others have added more photos to the main string.

Rebasing is unclipping your side photos and clipping them back on at the very end of the main string. Your work now sits on top of the latest version, in one straight line, as if you’d started from there all along.

Merge or rebase?

Both bring your branch together with main. They just leave a different history behind.

Teams pick whichever they prefer. Neither is wrong.

What it isn’t

It isn’t a backup or an undo. It moves your commits rather than saving anything new.

It also isn’t risk-free. Because it rewrites history, rebasing a branch other people already use can leave them with confusing duplicate commits.

Where the comparison breaks down

Moving a photo doesn’t change it. When Git rebases, it makes fresh copies of your commits on top of the new version. If the newer work changed the same lines, you may have to fix a merge conflict along the way.

How the words fit together

A branch holds your commits. Merging joins it back with a note. Rebasing replays it on the newest main instead, for a straighter history.

Watch out

Rebasing rewrites history. Your commits are replaced with new copies. Only rebase your own branches, never one that other people are already working from.

When you'll hear it

“Rebase onto main.” Bring your branch up to date by replaying it on top of the latest main version.

“I'd rather rebase than merge.” They prefer a tidy, straight-line history over one that shows every branch joining in.

“Don't rebase shared branches.” Rewriting history that other people rely on makes a mess for them.

Say it in a meeting

“Do we prefer merging or rebasing on this project?”

Try it yourselfReady to use it? The exact commands are on my other site, devcmds: Rebase your branch onto main ↗