Synopsis
git range-diff <range1> <range2>
git range-diff <base> <rev1> <rev2>
Description
The git range-diff command compares two sequences of commits (typically a branch before and after a rebase) and shows what changed between them at the patch level. This is far more useful than a regular git diff for reviewing rebases, because it pairs up corresponding commits and highlights only the substantive differences.
Pair this with --reroll-count on format-patch for upstream patch series, or just use it locally to verify that a force-push only introduced cleanup. Output uses a custom format with = for unchanged commits, ! for changed, < and > for missing or added.
In day-to-day use, git range-diff integrates closely with shell aliases, editor plugins, and continuous integration. Power users often add aliases that combine flags they always pass, or wrap the command in scripts that enforce team conventions. Output formatting can be customized via Git config — pretty formats, color schemes, and pager behavior are all tunable. When something goes wrong, the first diagnostic step is usually to re-run the command with GIT_TRACE=1 in the environment, which reveals the underlying plumbing calls. For unusual situations, the --help output (git range-diff --help) opens the full manual page with details on every option, including those rarely used in casual workflows but essential for debugging or scripting at scale.
Understanding how git range-diff interacts with the rest of Git's data model — the object database, the index, refs, and the working tree — pays dividends. Each command operates on some subset of these pieces, and knowing which it touches helps predict outcomes and recover from mistakes. Reading the official Git documentation alongside hands-on practice in a throwaway repository is the fastest way to internalize the nuances. Most production issues with Git stem from one of three causes: surprising default behavior, partial network operations, or rewriting history that was already shared. A working mental model of git range-diff's side effects helps avoid all three.
Common Options
| Option | Description |
|---|---|
--no-color | Disable color output. |
--creation-factor=<n> | Tunable for matching commits across ranges. |
--dual-color | Color both inner and outer diffs. |
--no-patch | Show only the matching summary, not patches. |
--notes | Include git notes in the comparison. |
Examples
git range-diff main..feature@{1} main..feature
# Compare branch before and after a rebase
git range-diff origin/main feature.v1 feature.v2
# Compare two patch series versions
git range-diff @{u}..HEAD HEAD@{1}..HEAD
# Compare current upstream-relative tip with what it was last time
Common Mistakes
Range-diff matches commits using a heuristic; if you make many small reorderings, the output may pair unexpected commits. Tune --creation-factor if needed. Don't confuse range-diff with git diff A..B — they answer different questions.
Related Commands
git diff, git log, git rebase, git format-patch