F1 old: 410994f F1 new: 5f347e1. Same author, same message, same file contents, and a different commit hash, because git rebase does not move commits. It builds replacements and walks away from the originals. git merge leaves the originals alone and ties the two lines together with one new commit. That single difference decides who on a team gets hurt and when. Every example below was run on an Ubuntu 24.04 test container with Git 2.43.0, using throwaway repositories and a local bare repository standing in for a shared remote.
Same three commits, two different histories
One branch, one hotfix, two ways to bring them together
The setup: a base commit A on main, a feature branch with two commits (F1, F2), and meanwhile a hotfix M1 landing on main. Two copies of the feature branch were made, one to merge and one to rebase.
The merge, run as git merge main from the feature branch:
* 952d0fd Merge branch 'main' into feature-merge
|\
| * c1b2bf5 M1: hotfix on main
* | 5893f1d F2: add tests
* | 410994f F1: add parser
|/
* abeac2f A: base
The rebase, run as git rebase main from the other copy:
Successfully rebased and updated refs/heads/feature-rebase.
* 6eb8e4d F2: add tests
* 5f347e1 F1: add parser
* c1b2bf5 M1: hotfix on main
* abeac2f A: base
The merge graph shows what happened: two lines of work running in parallel and a knot where they joined. The rebase graph shows a straight line, as if F1 were written after the hotfix landed. It was not. git range-diff lays out the swap:
$ git range-diff main feature feature-rebase
1: 410994f = 1: 5f347e1 F1: add parser
2: 5893f1d = 2: 6eb8e4d F2: add tests
The = signs say the patches are identical. The hashes on each side say they are different commits. Both statements are true at once, and that is the whole argument in two lines of output.

What each command does, by the manual
Merge records a meeting; rebase rewrites the minutes
The git-merge manual says merge “Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch,” and records the result “in a new commit along with the names of the two parent commits.” Two parents is the signature of a true merge.
There is a special case. When the current branch has not moved since the other one split off, Git does not need a merge commit; the manual says HEAD is simply updated to point at the named commit, “without creating an extra merge commit.” That is a fast-forward. --no-ff forces a merge commit anyway, and --ff-only refuses to merge at all unless a fast-forward is possible.
Rebase is described differently in Pro Git’s chapter on rebasing: “When you rebase stuff, you’re abandoning existing commits and creating new ones that are similar but different.” Each commit is replayed as a patch onto the new base, and each replay gets a new parent, so it gets a new hash, so every commit after it gets a new hash too. Change one link and the rest of the chain is recast from scratch.
The old commits are not deleted on the spot. They drop out of the branch and linger in the local reflog, which is how a botched rebase gets undone: git reflog lists the tip from before the rebase, and resetting to that hash puts the branch back.
The golden rule, broken on purpose
What a force-push does to the person downstream
Pro Git states the rule in bold: “Do not rebase commits that exist outside your repository and that people may have based work on.” The test on the container broke it on purpose.
Alice pushed feature with F1 and F2. Bob cloned it and added his own commit B1 on top. Then a hotfix M1 landed on main, Alice rebased feature onto it and force-pushed. Bob ran an ordinary git pull (merge mode):
* 6aeff97 Merge branch 'feature' of /tmp/gt/gr/origin into feature
|\
| * 3b81ab2 F2: add tests
| * a8a7984 F1: add parser
| * 6e22f21 M1: hotfix
* | dc05df8 B1: bob builds on feature
* | b244509 F2: add tests
* | cd8342c F1: add parser
|/
* 8a3d82b A: base
=== count of 'F1: add parser' commits in Bob's history: 2
Every one of Alice’s commits now exists twice in Bob’s history, once with the old hash and once with the new. Nothing conflicted, so nothing warned him. If Bob pushes this, the duplicates go back to the shared branch and stay there, a tangle of identical messages that confuses git log, code review and blame for the life of the project.
The git-rebase manual is blunt about it: rebasing a branch others have based work on “is a bad idea: anyone downstream of it is forced to manually fix their history.”

Cleaning up after a force-push
pull –rebase skips what it has already seen; –force-with-lease refuses to clobber
Pro Git’s advice for the case where it happens anyway is that everyone should run git pull --rebase to “make the pain after it happens a little bit simpler.” On the container, Bob reset to his pre-pull state and tried that:
$ git pull --rebase -q origin feature
* 318bc0f B1: bob builds on feature
* 3b81ab2 F2: add tests
* a8a7984 F1: add parser
* 6e22f21 M1: hotfix
* 8a3d82b A: base
One copy of each commit, with Bob’s work on top. It worked because, as the git-rebase manual explains, rebase “knows to skip changes that are already present in the new upstream” when their patch IDs match. Alice’s rewritten commits had identical diffs, so Git recognized and dropped Bob’s stale copies. Had Alice edited a commit during her rebase, the patch IDs would differ and Bob would be resolving it by hand.
The other half of the cleanup is on the pushing side. git push --force overwrites whatever the remote holds. The git-push manual describes --force-with-lease as allowing the overwrite only “if the current value of the remote ref is the expected value.” The test: Bob force-pushed his own version of feature; Alice, whose last view of the remote was older, then tried a lease push:
$ git push --force-with-lease origin feature
To /tmp/gt/gr/origin.git
! [rejected] feature -> feature (stale info)
error: failed to push some refs to '/tmp/gt/gr/origin.git'
Rejected, and correctly so: Alice was about to erase Bob’s push without having seen it. The same manual carries a warning worth taping to the monitor. A bare --force-with-lease “interacts very badly with anything that implicitly runs git fetch on the remote to be pushed to in the background,” because a background fetch updates the remote-tracking ref and the lease then looks valid. It suggests --force-if-includes alongside it to check that those background updates were actually integrated locally.
Where people get burned
One conflict for a merge, one per commit for a rebase
A merge resolves conflicts once, at the knot. A rebase replays commits one at a time, and the manual says it “will stop at the first problematic commit and leave conflict markers.” If several commits touch the same lines that changed upstream, the stops repeat.
The test: main reformatted every line of a small config file (host=a became host = a), while the feature branch had three commits, each changing one value. Merging the reformat in conflicted once. Rebasing onto it stopped three times:
merge conflicted files: 1, stops: 1
stop 1 at: host b
stop 2 at: port 2
stop 3 at: user y
rebase stops: 3
An earlier run with a different shape of change, where every feature commit edited the same single line, stopped only once, because after the first resolution the later commits applied cleanly. The count depends on how the edits overlap, which is exactly why it surprises people. A ten-commit branch against a big upstream refactor can mean ten rounds of the same argument with the same file.
Other failure modes:
- Panic mid-rebase.
git rebase --abortresetsHEAD“to the original branch,” per the manual. It is the emergency stop and it works, but only before the rebase finishes. After that, the reflog is the route back. - Trusting ORIG_HEAD. The manual says ORIG_HEAD “is not guaranteed to still point to that commit” if other commands change it during the rebase, and points to the branch reflog,
@{1}, as the reliable way to find the previous tip. - Rebasing a shared branch because the graph looks messy. That is the golden-rule case above, and the person who pays is rarely the one who ran the command.
- Assuming a rebased branch was tested. The new commits combine the feature with code it was never run against.
F1on top ofM1is a commit nobody compiled until the moment the rebase invented it.

Which one to use
A record of what happened, or a story of how it was built
Pro Git frames the dispute as two views of history. One holds that the log is a “record of what actually happened,” so rewriting it is lying about the past. The other treats it as the “story of how your project was made,” something to edit before publishing, the way a first draft gets cleaned up before print.
Both camps have a real point. A straight history is easier to read and easier to search; git bisect walks a line of commits to find where a bug came in, and a line with no knots is a simpler thing to walk. Merge commits, on the other hand, preserve the one fact rebase erases: that two pieces of work were developed apart and met at a specific point, with a specific resolution, that someone can inspect later.
The strongest case against routine rebasing is the last bullet in the previous section. Every rebase manufactures commits that never existed on anyone’s machine before, and a clean graph hides that. The strongest case against routine merging is a log so braided with “Merge branch ‘main’ into feature” commits that no one reads it at all.
Pro Git offers a compromise: “rebase local changes before pushing to clean up your work, but never rebase anything that you’ve pushed somewhere.” For a one-person home-lab repository, like the folder of files behind a Docker Compose self-hosted stack, the golden rule barely applies, since there is no downstream to hurt. On a shared branch it is the whole game.
The duplicated F1: add parser in Bob’s log is the image that stays. Two commits with the same message and the same diff sit under two hashes, no error ever appeared, and the only clue is a count that should have been one. How many shared repositories carry a pair like that from a force-push years ago that nobody ever traced?
Sources
- git-merge documentation: https://git-scm.com/docs/git-merge
- git-rebase documentation: https://git-scm.com/docs/git-rebase
- git-push documentation: https://git-scm.com/docs/git-push
- Pro Git, 2nd edition, section 3.6 Git Branching, Rebasing: https://git-scm.com/book/en/v2/Git-Branching-Rebasing
