← Software Engineering Studio
Concept Explainer · Software Engineering

Git Rebase vs Merge

Both combine two branches. The difference is what the history looks like afterward — and whether you're allowed to rewrite it.

`git merge` and `git rebase` both integrate changes from one branch into another, and in most cases produce identical final file contents. What differs is the resulting commit graph. Merge adds a new "merge commit" that has two parents, faithfully recording that two branches diverged and were joined back together — the history is a true, if messier, record of what actually happened. Rebase instead takes your branch's commits and replays them one-by-one on top of the target branch's latest commit, producing a straight, linear history that looks as if you had started your branch from that latest commit all along. The commits themselves get new hashes because their parent has changed — this is the key fact that makes rebase dangerous on shared history.