LinuxCommandLibrary

git-range-diff

Compare commit ranges between two branches

TLDR

Diff the changes of two individual commits

$ git range-diff [commit_1]^! [commit_2]^!
copy

Diff the changes of ours and theirs from their common ancestor, e.g. after an interactive rebase
$ git range-diff [theirs]...[ours]
copy

Diff the changes of two commit ranges, e.g. to check whether conflicts have been resolved appropriately when rebasing commits from base1 to base2
$ git range-diff [base1]..[rev1] [base2]..[rev2]
copy

SYNOPSIS

git range-diff [--color[=<when>] | --no-color] [--stat[=<width>|off] | --no-stat] [--summary] [-c|-C <n> | --creation-factor=<n>] [--no-dual-color] [--no-renames] [--notes[=<ref>] | --no-notes] [--no-ff] <old-range> <new-range>

PARAMETERS

--color[=<when>]
    Enable color output; when is always, never, auto (default).

--no-color
    Disable color output.

--stat[=<width>|off]
    Show diffstat; limit width or off.

--no-stat
    Do not show diffstat.

--summary
    Show summary of range diffs.

-c | -C <n>
    Set creation-factor to n% (default 60).

--creation-factor=<n>
    Similarity threshold for creations/deletions.

--no-dual-color
    Disable dual-color mode for changes.

--no-renames
    Disable rename detection.

--notes[=<ref>]
    Show notes from ref (default refs/notes/commits).

--no-notes
    Do not show notes.

--no-ff
    Do not skip unchanged final commits.

DESCRIPTION

git range-diff compares two ranges of commits, producing a side-by-side diff summary ideal for reviewing changes between patch series iterations. It pairs commits by position (first with first, etc.) and diffs their individual diffs, highlighting modifications to changes.

Key uses include comparing v1 to v2 of a series on mailing lists or locally. Output is compact: commit summaries, diffstats, and abbreviated diffs of changes. It handles insertions/deletions via --creation-factor, treating small similarity as rename/create.

Invoke with two range specs like old~3..old new~3..new. Supports color, stats, summaries, and notes. Dual-color mode differentiates old/new changes distinctly. Useful for bisecting series evolution or verifying rebases.

Limitations: positional pairing assumes similar range lengths; mismatches may confuse output without tuning.

CAVEATS

Positional pairing assumes similar range structures; insertions/deletions may misalign without --creation-factor. Not for arbitrary ranges—best for patch series.

EXAMPLES

git range-diff v1~2..v1 v2~2..v2
Compare last two patches of v1/v2 tags.

git range-diff main~3.. main~0^{1} next~3..next~0^{1}
Compare recent 3 commits on branches.

RANGE SPECS

Use .. for ranges, ~n for ancestors, ^{1} for parents. E.g., HEAD~4..HEAD~1 for last 3.

HISTORY

Introduced in Git 2.19 (June 2018) by Stefan Beller to simplify patch series reviews on lists like lore.kernel.org.

SEE ALSO

Copied to clipboard