Skip to content
BENIBIX Learn

Merge vs Rebase

Both join two branches. A merge keeps both lines and ties them with a new commit; a rebase moves your commits into one line.

Development🔀 Version Control

Merge

Joining work from one branch into another. Both sets of changes end up in one place.

A merge joins the work from one branch into another. Git compares the two lines of commits and combines the changes. If only one side moved on, Git just moves the branch forward, which is called a fast-forward. If both sides changed, Git makes a new merge commit that ties them together. If both changed the same lines, you get a merge conflict to sort out by hand.

Example
Emma finishes dark-mode and merges it into main. Her new style is now part of the main code.
Why it matters
Merging is how separate work becomes one product. It happens many times a day on a busy team.
Full entry
Development🔀 Version Control

Rebase

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

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
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.
Full entry

In one line

Merge
Joining work from one branch into another. Both sets of changes end up in one place.
Rebase
Your commits move to start from a newer point. The past reads as one line.