Machine Room

Git Merge vs Git Rebase

Both join two branches. The difference is what they do to your history. The one-page notes from the reel.

Download the PDF

One-page notes on git merge vs git rebase with four commit graphs: the use case (a feature branch off main with login form and email validation, a bug fix pushed to main); git merge makes one new merge commit on top and your commits keep their IDs; git rebase replays your two commits after the bug fix as new commits with new IDs, one straight line; where rebase goes wrong: a colleague's commit still points at the old email validation commit, git sees two histories of the same work and your work shows up twice, with conflicts; the golden rule of rebasing: before you rebase, ask one question, is anyone else looking at this branch? If yes, hands off the keyboard, merge. Rebase while the branch is only yours. Once others have it, merge. Same code either way.

On a phone, press and hold the image to save it. The reel: Git Merge vs Rebase: The Golden Rule of Rebasing.