Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

Git Merge vs Rebase (2026): What Each Does to History

Your feature branch has fallen behind main, and a teammate is waiting to review it. Merge joins the two histories with a merge commit and leaves your commits untouched; rebase replays your commits on top of the new tip for a linear history, as new commits. The code ends up identical, so rebase work only you have, and merge anything already pushed.

Bringing a branch up to date takes a few seconds of typing and, on plenty of teams, a long argument. Below, the two commands sit in no particular order, explained from Git's own reference documentation and the Pro Git book, so you can decide on the history you'll be happy to read later rather than on habit.

What a merge records

Git's own docs describe merge as joining two or more development histories together. In practice, git merge incorporates changes from the named commits into the branch you're on. Nothing that already exists is rewritten. Your commits keep their identities, and so do everyone else's.

When both branches have moved on, the Pro Git book explains that a standard merge does a three-way merge against the common ancestor of the two branches, then creates a new snapshot and a new commit to tie them together. That merge commit is the visible record that two lines of work met at that point, and it stays in the log for anyone who looks later.

When only one side has moved, things are simpler. A fast-forward merge doesn't create a merge commit at all; the branch just catches up. If you'd like to be certain about what a merge will do before anything lands, the docs suggest pairing --no-ff with --no-commit, so you can be sure the branch isn't changed by the merge command itself.

What a rebase rewrites

Git's docs describe rebase as reapplying commits on top of another base tip. Rather than tying two histories together, git rebase picks up your commits and plays them again from a new starting point, one after another.

The Pro Git book puts the difference neatly: rebasing replays changes in the order they were introduced, while merging takes the endpoints and merges them. The result, in the book's words, is a cleaner, linear-looking history. Read the log afterwards and your feature looks as if it was started from the latest work, with no merge commit in the middle.

Because the replay happens commit by commit, a rebase can stop partway when one of those commits clashes with the new base. That's why it comes with its own set of controls: continue, skip, abort, quit, edit-todo and show-current-patch. Abort is the one to remember, since it takes you back to where you were before you started.

The catch: same snapshot, different story

Here's the part that settles most arguments. The Pro Git book points out that both commands end on the same final snapshot. Merge your branch or rebase it, and the files at the tip are identical. The only thing that differs is the recorded history.

So the decision isn't about the quality or safety of the code itself. It's about what you want the log to say. Merge keeps a faithful record of how the work happened, branches and all. Rebase tells a tidier story in which the work arrives in a straight line. Both are honest about the code; they differ in how much of the journey they keep.

Once you see it that way, team debates get much shorter. Agree on the shape of history you'd like to read months from now, when you're hunting for the commit that broke something, and the command follows from that. Some teams want the full record for auditing who did what and when; others want a log a newcomer can read top to bottom. Both are reasonable, and both are reachable with either command used consistently.

The rewritten commits trap

There's one mistake that turns a tidy habit into a team problem. The Pro Git book explains that rebasing abandons existing commits and creates new, similar ones. On your own machine, before anyone else has seen them, that's harmless. On work you've already pushed, it's risky, because anyone who built on the old commits now has history that no longer matches yours.

That's the reason behind the usual rule of thumb: rebase what only you have, merge what others can see. If you ever do need to rebase shared work, tell the people on that branch before you push it, not after they've found out the hard way.

A quick check before any rebase saves most of the pain: could anyone else have pulled this branch? If the answer is yes, or you're not sure, merge instead. You lose a little tidiness in the log and keep everyone's history intact.

Merge and rebase at a glance

Each command is listed alphabetically, in no particular order, with what Git's documentation says it does.

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

ToolWhat it does to historyWhere it fits
git mergeJoin histories, keeps branch shapeShared branches and a full record of the work
git rebaseReapply commits on a new base, linear historyLocal work you want to read as a straight line

git merge

Best for: Keeping every existing commit unchanged; Git's own docs describe merge as joining two or more development histories together.

git rebase

Best for: Tidying local work before review; Git's own docs describe rebase as reapplying commits on top of another base tip.

A house rule your team can agree on

Write the rule down in one sentence and put it in your contributing notes: rebase your own local branch onto the latest main before you open a pull request, and merge once the branch is shared. That gives reviewers the linear-looking history the Pro Git book describes, without anyone's pushed commits being replaced underneath them.

If you're newer to this, practise on a throwaway branch first, and keep abort in mind for when a rebase stops partway. When it does stop on a clash, show-current-patch tells you which of your commits it was replaying, which makes the conflict far easier to understand. My guide on how to use GitHub covers the everyday workflow around pull requests, and if your team is still deciding where the code lives, GitLab vs GitHub and GitHub vs Bitbucket compare popular places to host it.

Do you make Git tools or developer workflow software? Tool makers can ask to be considered for a featured place on this list.

Want your tool on this list? Featured spots and reviews here are paid partnerships. Here's how to partner with me.

Frequently asked questions

Does rebase change my code?

No. The Pro Git book says merge and rebase end on the same final snapshot; only the recorded history differs.

Is it safe to rebase a branch I've already pushed?

It's risky. Rebasing abandons existing commits and creates new, similar ones, so anyone working from the old commits ends up with history that no longer matches.

When does a merge not create a merge commit?

When it's a fast-forward. Git's docs say fast-forward merges don't create a merge commit.

How do I get out of a rebase that's gone wrong?

Rebase has its own controls, including abort, continue, skip and quit. Abort returns you to the state before the rebase began.

What is a three-way merge?

It's how a standard merge works when both branches have moved on: Git works from the two branch tips and their common ancestor, then creates a new snapshot and commit, as the Pro Git book explains.

Why do people rebase at all?

The Pro Git book says rebasing gives a cleaner, linear-looking history, which is easier to scan in the log.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.