{
    "mode": "man",
    "parameter": "git-range-diff",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-range-diff/1/json",
    "generated": "2026-06-27T16:08:09Z",
    "synopsis": "git range-diff [--color=[<when>]] [--no-color] [<diff-options>]\n[--no-dual-color] [--creation-factor=<factor>]\n[--left-only | --right-only]\n( <range1> <range2> | <rev1>...<rev2> | <base> <rev1> <rev2> )",
    "sections": {
        "NAME": {
            "content": "git-range-diff - Compare two commit ranges (e.g. two versions of a branch)\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git range-diff [--color=[<when>]] [--no-color] [<diff-options>]\n[--no-dual-color] [--creation-factor=<factor>]\n[--left-only | --right-only]\n( <range1> <range2> | <rev1>...<rev2> | <base> <rev1> <rev2> )\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This command shows the differences between two versions of a patch series, or more generally,\ntwo commit ranges (ignoring merge commits).\n\nTo that end, it first finds pairs of commits from both commit ranges that correspond with\neach other. Two commits are said to correspond when the diff between their patches (i.e. the\nauthor information, the commit message and the commit diff) is reasonably small compared to\nthe patches' size. See ``Algorithm`` below for details.\n\nFinally, the list of matching commits is shown in the order of the second commit range, with\nunmatched commits being inserted just after all of their ancestors have been shown.\n\nThere are three ways to specify the commit ranges:\n\n•   <range1> <range2>: Either commit range can be of the form <base>..<rev>, <rev>^!  or\n<rev>^-<n>. See SPECIFYING RANGES in gitrevisions(7) for more details.\n\n•   <rev1>...<rev2>. This is equivalent to <rev2>..<rev1> <rev1>..<rev2>.\n\n•   <base> <rev1> <rev2>: This is equivalent to <base>..<rev1> <base>..<rev2>.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "--no-dual-color",
                    "content": "When the commit diffs differ, ‘git range-diff` recreates the original diffs’ coloring,\nand adds outer -/+ diff markers with the background being red/green to make it easier to\nsee e.g. when there was a change in what exact lines were added.\n\nAdditionally, the commit diff lines that are only present in the first commit range are\nshown \"dimmed\" (this can be overridden using the color.diff.<slot> config setting where\n<slot> is one of contextDimmed, oldDimmed and newDimmed), and the commit diff lines that\nare only present in the second commit range are shown in bold (which can be overridden\nusing the config settings color.diff.<slot> with <slot> being one of contextBold, oldBold\nor newBold).\n\nThis is known to range-diff as \"dual coloring\". Use --no-dual-color to revert to color\nall lines according to the outer diff markers (and completely ignore the inner diff when\nit comes to color).\n\n--creation-factor=<percent>\nSet the creation/deletion cost fudge factor to <percent>. Defaults to 60. Try a larger\nvalue if git range-diff erroneously considers a large change a total rewrite (deletion of\none commit and addition of another), and a smaller one in the reverse case. See the\n``Algorithm`` section below for an explanation why this is needed.\n",
                    "long": "--no-dual-color"
                },
                {
                    "name": "--left-only",
                    "content": "Suppress commits that are missing from the first specified range (or the \"left range\"\nwhen using the <rev1>...<rev2> format).\n",
                    "long": "--left-only"
                },
                {
                    "name": "--right-only",
                    "content": "Suppress commits that are missing from the second specified range (or the \"right range\"\nwhen using the <rev1>...<rev2> format).\n\n--[no-]notes[=<ref>]\nThis flag is passed to the git log program (see git-log(1)) that generates the patches.\n\n<range1> <range2>\nCompare the commits specified by the two ranges, where <range1> is considered an older\nversion of <range2>.\n\n<rev1>...<rev2>\nEquivalent to passing <rev2>..<rev1> and <rev1>..<rev2>.\n\n<base> <rev1> <rev2>\nEquivalent to passing <base>..<rev1> and <base>..<rev2>. Note that <base> does not need\nto be the exact branch point of the branches. Example: after rebasing a branch my-topic,\ngit range-diff my-topic@{u} my-topic@{1} my-topic would show the differences introduced\nby the rebase.\n\ngit range-diff also accepts the regular diff options (see git-diff(1)), most notably the\n--color=[<when>] and --no-color options. These options are used when generating the \"diff\nbetween patches\", i.e. to compare the author, commit message and diff of corresponding\nold/new commits. There is currently no means to tweak most of the diff options passed to git\nlog when generating those patches.\n",
                    "long": "--right-only"
                }
            ]
        },
        "OUTPUT STABILITY": {
            "content": "The output of the range-diff command is subject to change. It is intended to be\nhuman-readable porcelain output, not something that can be used across versions of Git to get\na textually stable range-diff (as opposed to something like the --stable option to git-patch-\nid(1)). There’s also no equivalent of git-apply(1) for range-diff, the output is not intended\nto be machine-readable.\n\nThis is particularly true when passing in diff options. Currently some options like --stat\ncan, as an emergent effect, produce output that’s quite useless in the context of range-diff.\nFuture versions of range-diff may learn to interpret such options in a manner specific to\nrange-diff (e.g. for --stat producing human-readable output which summarizes how the diffstat\nchanged).\n",
            "subsections": []
        },
        "CONFIGURATION": {
            "content": "This command uses the diff.color.* and pager.range-diff settings (the latter is on by\ndefault). See git-config(1).\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "When a rebase required merge conflicts to be resolved, compare the changes introduced by the\nrebase directly afterwards using:\n\n$ git range-diff @{u} @{1} @\n\n\nA typical output of git range-diff would look like this:\n\n-:  ------- > 1:  0ddba11 Prepare for the inevitable!\n1:  c0debee = 2:  cab005e Add a helpful message at the start\n2:  f00dbal ! 3:  decafe1 Describe a bug\n@@ -1,3 +1,3 @@\nAuthor: A U Thor <author@example.com>\n\n-TODO: Describe a bug\n+Describe a bug\n@@ -324,5 +324,6\nThis is expected.\n\n-+What is unexpected is that it will also crash.\n++Unexpectedly, it also crashes. This is a bug, and the jury is\n++still out there how to fix it best. See ticket #314 for details.\n\nContact\n3:  bedead < -:  ------- TO-UNDO\n\n\nIn this example, there are 3 old and 3 new commits, where the developer removed the 3rd,\nadded a new one before the first two, and modified the commit message of the 2nd commit as\nwell its diff.\n\nWhen the output goes to a terminal, it is color-coded by default, just like regular git\ndiff's output. In addition, the first line (adding a commit) is green, the last line\n(deleting a commit) is red, the second line (with a perfect match) is yellow like the commit\nheader of git show's output, and the third line colors the old commit red, the new one green\nand the rest like git show's commit header.\n\nA naive color-coded diff of diffs is actually a bit hard to read, though, as it colors the\nentire lines red or green. The line that added \"What is unexpected\" in the old commit, for\nexample, is completely red, even if the intent of the old commit was to add something.\n\nTo help with that, range uses the --dual-color mode by default. In this mode, the diff of\ndiffs will retain the original diff colors, and prefix the lines with -/+ markers that have\ntheir background red or green, to make it more obvious that they describe how the diff itself\nchanged.\n",
            "subsections": []
        },
        "ALGORITHM": {
            "content": "The general idea is this: we generate a cost matrix between the commits in both commit\nranges, then solve the least-cost assignment.\n\nThe cost matrix is populated thusly: for each pair of commits, both diffs are generated and\nthe \"diff of diffs\" is generated, with 3 context lines, then the number of lines in that diff\nis used as cost.\n\nTo avoid false positives (e.g. when a patch has been removed, and an unrelated patch has been\nadded between two iterations of the same patch series), the cost matrix is extended to allow\nfor that, by adding fixed-cost entries for wholesale deletes/adds.\n\nExample: Let commits 1--2 be the first iteration of a patch series and A--C the second\niteration. Let’s assume that A is a cherry-pick of 2, and C is a cherry-pick of 1 but with a\nsmall modification (say, a fixed typo). Visualize the commits as a bipartite graph:\n\n1            A\n\n2            B\n\nC\n\n\nWe are looking for a \"best\" explanation of the new series in terms of the old one. We can\nrepresent an \"explanation\" as an edge in the graph:\n\n1            A\n/\n2 --------'  B\n\nC\n\n\nThis explanation comes for \"free\" because there was no change. Similarly C could be explained\nusing 1, but that comes at some cost c>0 because of the modification:\n\n1 ----.      A\n|    /\n2 ----+---'  B\n|\n`----- C\nc>0\n\n\nIn mathematical terms, what we are looking for is some sort of a minimum cost bipartite\nmatching; ‘1` is matched to C at some cost, etc. The underlying graph is in fact a complete\nbipartite graph; the cost we associate with every edge is the size of the diff between the\ntwo commits’ patches. To explain also new commits, we introduce dummy nodes on both sides:\n\n1 ----.      A\n|    /\n2 ----+---'  B\n|\no     `----- C\nc>0\no            o\n\no            o\n\n\nThe cost of an edge o--C is the size of C's diff, modified by a fudge factor that should be\nsmaller than 100%. The cost of an edge o--o is free. The fudge factor is necessary because\neven if 1 and C have nothing in common, they may still share a few empty lines and such,\npossibly making the assignment 1--C, o--o slightly cheaper than 1--o, o--C even if 1 and C\nhave nothing in common. With the fudge factor we require a much larger common part to\nconsider patches as corresponding.\n\nThe overall time needed to compute this algorithm is the time needed to compute n+m commit\ndiffs and then n*m diffs of patches, plus the time needed to compute the least-cost\nassignment between n and m diffs. Git uses an implementation of the Jonker-Volgenant\nalgorithm to solve the assignment problem, which has cubic runtime complexity. The matching\nfound in this case will look like this:\n\n1 ----.      A\n|    /\n2 ----+---'  B\n.--+-----'\no -'  `----- C\nc>0\no ---------- o\n\no ---------- o\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "git-log(1)\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\n\n\nGit 2.34.1                                   02/26/2026                            GIT-RANGE-DIFF(1)",
            "subsections": []
        }
    },
    "summary": "git-range-diff - Compare two commit ranges (e.g. two versions of a branch)",
    "flags": [
        {
            "flag": "",
            "long": "--no-dual-color",
            "arg": null,
            "description": "When the commit diffs differ, ‘git range-diff` recreates the original diffs’ coloring, and adds outer -/+ diff markers with the background being red/green to make it easier to see e.g. when there was a change in what exact lines were added. Additionally, the commit diff lines that are only present in the first commit range are shown \"dimmed\" (this can be overridden using the color.diff.<slot> config setting where <slot> is one of contextDimmed, oldDimmed and newDimmed), and the commit diff lines that are only present in the second commit range are shown in bold (which can be overridden using the config settings color.diff.<slot> with <slot> being one of contextBold, oldBold or newBold). This is known to range-diff as \"dual coloring\". Use --no-dual-color to revert to color all lines according to the outer diff markers (and completely ignore the inner diff when it comes to color). --creation-factor=<percent> Set the creation/deletion cost fudge factor to <percent>. Defaults to 60. Try a larger value if git range-diff erroneously considers a large change a total rewrite (deletion of one commit and addition of another), and a smaller one in the reverse case. See the ``Algorithm`` section below for an explanation why this is needed."
        },
        {
            "flag": "",
            "long": "--left-only",
            "arg": null,
            "description": "Suppress commits that are missing from the first specified range (or the \"left range\" when using the <rev1>...<rev2> format)."
        },
        {
            "flag": "",
            "long": "--right-only",
            "arg": null,
            "description": "Suppress commits that are missing from the second specified range (or the \"right range\" when using the <rev1>...<rev2> format). --[no-]notes[=<ref>] This flag is passed to the git log program (see git-log(1)) that generates the patches. <range1> <range2> Compare the commits specified by the two ranges, where <range1> is considered an older version of <range2>. <rev1>...<rev2> Equivalent to passing <rev2>..<rev1> and <rev1>..<rev2>. <base> <rev1> <rev2> Equivalent to passing <base>..<rev1> and <base>..<rev2>. Note that <base> does not need to be the exact branch point of the branches. Example: after rebasing a branch my-topic, git range-diff my-topic@{u} my-topic@{1} my-topic would show the differences introduced by the rebase. git range-diff also accepts the regular diff options (see git-diff(1)), most notably the --color=[<when>] and --no-color options. These options are used when generating the \"diff between patches\", i.e. to compare the author, commit message and diff of corresponding old/new commits. There is currently no means to tweak most of the diff options passed to git log when generating those patches."
        }
    ],
    "examples": [
        "When a rebase required merge conflicts to be resolved, compare the changes introduced by the",
        "rebase directly afterwards using:",
        "$ git range-diff @{u} @{1} @",
        "A typical output of git range-diff would look like this:",
        "-:  ------- > 1:  0ddba11 Prepare for the inevitable!",
        "1:  c0debee = 2:  cab005e Add a helpful message at the start",
        "2:  f00dbal ! 3:  decafe1 Describe a bug",
        "@@ -1,3 +1,3 @@",
        "Author: A U Thor <author@example.com>",
        "-TODO: Describe a bug",
        "+Describe a bug",
        "@@ -324,5 +324,6",
        "This is expected.",
        "-+What is unexpected is that it will also crash.",
        "++Unexpectedly, it also crashes. This is a bug, and the jury is",
        "++still out there how to fix it best. See ticket #314 for details.",
        "Contact",
        "3:  bedead < -:  ------- TO-UNDO",
        "In this example, there are 3 old and 3 new commits, where the developer removed the 3rd,",
        "added a new one before the first two, and modified the commit message of the 2nd commit as",
        "well its diff.",
        "When the output goes to a terminal, it is color-coded by default, just like regular git",
        "diff's output. In addition, the first line (adding a commit) is green, the last line",
        "(deleting a commit) is red, the second line (with a perfect match) is yellow like the commit",
        "header of git show's output, and the third line colors the old commit red, the new one green",
        "and the rest like git show's commit header.",
        "A naive color-coded diff of diffs is actually a bit hard to read, though, as it colors the",
        "entire lines red or green. The line that added \"What is unexpected\" in the old commit, for",
        "example, is completely red, even if the intent of the old commit was to add something.",
        "To help with that, range uses the --dual-color mode by default. In this mode, the diff of",
        "diffs will retain the original diff colors, and prefix the lines with -/+ markers that have",
        "their background red or green, to make it more obvious that they describe how the diff itself",
        "changed."
    ],
    "see_also": [
        {
            "name": "git-log",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-log/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Compare two commit ranges (e.g. two versions of a branch).",
        "examples": [
            {
                "description": "Diff the changes of two individual commits",
                "command": "git range-diff {{commit_1}}^! {{commit_2}}^!"
            },
            {
                "description": "Diff the changes of ours and theirs from their common ancestor, e.g. after an interactive rebase",
                "command": "git range-diff {{theirs}}...{{ours}}"
            },
            {
                "description": "Diff the changes of two commit ranges, e.g. to check whether conflicts have been resolved appropriately when rebasing commits from `base1` to `base2`",
                "command": "git range-diff {{base1}}..{{rev1}} {{base2}}..{{rev2}}"
            }
        ]
    }
}