git range-diff for Rewritten Series
git range-diff for Rewritten Series
Thesis
git range-diff compares two revisions of a patch series — after rebase, amend, or squash — and shows how each commit changed. It answers “what did I alter while rewriting?” better than a single diff of tips.
Mental model
old: A—B—C
new: A'—B'—C' (rebased)
range-diff old...new
→ per-commit pairwise diffs of patches
Matching uses patch-id heuristics; order and subject help correspondence.
Worked example
# create a tiny series, rebase-edit, then range-diff
git range-diff <old-tip>...<new-tip>
# or after a rebase:
git range-diff ORIG_HEAD...HEAD1: 8a2c39b < -: ------- add f
2: 62c3d72 = 1: 7c1560d patch1
3: 2aebe57 < -: ------- patch2
-: ------- > 2: 1ad4b63 patch2 v2
Trap
Diffing only old..new trees. That shows net effect, not which commit in the series absorbed the change. Also: heavy squashing into one commit makes range-diff less informative — there is nothing left to pair.
Boring rule
After interactive rebase of a published-but-not-merged series, run git range-diff ORIG_HEAD...HEAD before force-push and paste the interesting hunks into the PR.
Try this
- Reorder two commits with
rebase -iand read the range-diff. - Amend a commit message only — range-diff should show a message-only change.
- Compare with
git range-diff --creation-factor=100.
Sources
git range-diffdocumentation- Git release notes introducing range-diff (2.19 era) and later improvements