Skip to content
explainroo

git merge vs rebase

Merge and rebase both bring your branch up to date with main. This short shows what each one does to the history, and when you should not rebase.

Transcript

Your branch is behind main. You can merge it, or you can rebase it.

A merge adds one new commit that joins the two histories.

A rebase takes your commits off your branch and adds them again on top of main, one after the other.

These are new commits, so they get new hashes.

So don’t rebase a branch that other people have already pulled. Their copy still has the old commits.

A merge keeps the history the way it happened. A rebase turns it into a straight line, which is easier to read.

More from technology