1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
6 <meta http-equiv=
"Content-Type" content=
"application/xhtml+xml; charset=UTF-8" />
7 <meta name=
"generator" content=
"AsciiDoc 10.2.0" />
8 <title>git-diff-index(
1)
</title>
9 <style type=
"text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.5em;
129 margin-bottom:
1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
228 div.imageblock div.content { padding-left:
0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size:
2em; }
411 span.small { font-size:
0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
443 div.tableblock
> table[
frame=
"hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock
> table[
frame=
"vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
480 border-color: #
527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-top {
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September
2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September
2006. License: GPL */
559 /* modified by Stuart Rackham,
2006,
2009. License: GPL */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([
1-'+(toclevels+
1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType ==
1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute(
"class") || i.getAttribute(
"className")) !=
"float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[
1]-
1);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
610 for (i =
0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute(
"class")
614 && entry.getAttribute(
"class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i =
0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById(
"content"), toclevels);
623 for (var i =
0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id ==
"")
626 entry.element.id =
"_toc_" + i;
627 var a = document.createElement(
"a");
628 a.href =
"#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement(
"div");
632 div.className =
"toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length ==
0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/
2005/
07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
651 var noteholder = document.getElementById(
"footnotes");
655 var entriesToRemove = [];
656 for (i =
0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute(
"class") ==
"footnote")
659 entriesToRemove.push(entry);
661 for (i =
0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById(
"content");
667 var spans = cont.getElementsByTagName(
"span");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-note");
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[
1];
679 "[<a id='_footnoteref_" + n +
"' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n +
"</a>]";
681 spans[i].setAttribute(
"data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n +
"'>" +
685 "<a href='#_footnoteref_" + n +
"' title='Return to text'>" +
686 n +
"</a>. " + note +
"</div>";
687 var id =spans[i].getAttribute(
"id");
688 if (id != null) refs[
"#"+id] = n;
692 noteholder.parentNode.removeChild(noteholder);
694 // Process footnoterefs.
695 for (i=
0; i
<spans.length; i++) {
696 if (spans[i].className ==
"footnoteref") {
697 var href = spans[i].getElementsByTagName(
"a")[
0].getAttribute(
"href");
698 href = href.match(/#.*/)[
0]; // Because IE return full URL.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 git-diff-index(
1) Manual Page
741 <div class=
"sectionbody">
743 Compare a tree to the working tree or index
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><em>git diff-index
</em> [-m] [--cached] [--merge-base] [
<common-diff-options
>]
<tree-ish
> [
<path
>…]
</pre>
753 <div class=
"attribution">
758 <h2 id=
"_description">DESCRIPTION
</h2>
759 <div class=
"sectionbody">
760 <div class=
"paragraph"><p>Compare the content and mode of the blobs found in a tree object
761 with the corresponding tracked files in the working tree, or with the
762 corresponding paths in the index. When
<path
> arguments are present,
763 compare only paths matching those patterns. Otherwise all tracked
764 files are compared.
</p></div>
768 <h2 id=
"_options">OPTIONS
</h2>
769 <div class=
"sectionbody">
770 <div class=
"dlist"><dl>
782 Generate patch (see
<a href=
"#generate_patch_text_with_p">[generate_patch_text_with_p]
</a>).
793 Suppress all output from the diff machinery. Useful for
794 commands like
<code>git show
</code> that show the patch by default to
795 squelch their output, or to cancel the effect of options like
796 <code>--patch
</code>,
<code>--stat
</code> earlier on the command line in an alias.
807 Generate diffs with
<n
> lines of context instead of
809 Implies
<code>--patch
</code>.
813 --output=
<file
>
817 Output to a specific file instead of stdout.
821 --output-indicator-new=
<char
>
824 --output-indicator-old=
<char
>
827 --output-indicator-context=
<char
>
831 Specify the character used to indicate new, old or context
832 lines in the generated patch. Normally they are
<em>+
</em>,
<em>-
</em> and
841 Generate the diff in raw format.
850 Synonym for
<code>-p --raw
</code>.
858 Enable the heuristic that shifts diff hunk boundaries to make patches
859 easier to read. This is the default.
863 --no-indent-heuristic
867 Disable the indent heuristic.
875 Spend extra time to make sure the smallest possible
884 Generate a diff using the
"patience diff" algorithm.
892 Generate a diff using the
"histogram diff" algorithm.
896 --anchored=
<text
>
900 Generate a diff using the
"anchored diff" algorithm.
902 <div class=
"paragraph"><p>This option may be specified more than once.
</p></div>
903 <div class=
"paragraph"><p>If a line exists in both the source and destination, exists only once,
904 and starts with this text, this algorithm attempts to prevent it from
905 appearing as a deletion or addition in the output. It uses the
"patience
906 diff" algorithm internally.
</p></div>
909 --diff-algorithm={patience|minimal|histogram|myers}
913 Choose a diff algorithm. The variants are as follows:
915 <div class=
"openblock">
916 <div class=
"content">
917 <div class=
"dlist"><dl>
919 <code>default
</code>,
<code>myers
</code>
923 The basic greedy diff algorithm. Currently, this is the default.
931 Spend extra time to make sure the smallest possible diff is
936 <code>patience
</code>
940 Use
"patience diff" algorithm when generating patches.
944 <code>histogram
</code>
948 This algorithm extends the patience algorithm to
"support
949 low-occurrence common elements".
954 <div class=
"paragraph"><p>For instance, if you configured the
<code>diff.algorithm
</code> variable to a
955 non-default value and want to use the default one, then you
956 have to use
<code>--diff-algorithm=default
</code> option.
</p></div>
959 --stat[=
<width
>[,
<name-width
>[,
<count
>]]]
963 Generate a diffstat. By default, as much space as necessary
964 will be used for the filename part, and the rest for the graph
965 part. Maximum width defaults to terminal width, or
80 columns
966 if not connected to a terminal, and can be overridden by
967 <code><width
></code>. The width of the filename part can be limited by
968 giving another width
<code><name-width
></code> after a comma or by setting
969 <code>diff.statNameWidth=
<width
></code>. The width of the graph part can be
970 limited by using
<code>--stat-graph-width=
<width
></code> or by setting
971 <code>diff.statGraphWidth=
<width
></code>. Using
<code>--stat
</code> or
972 <code>--stat-graph-width
</code> affects all commands generating a stat graph,
973 while setting
<code>diff.statNameWidth
</code> or
<code>diff.statGraphWidth
</code>
974 does not affect
<code>git format-patch
</code>.
975 By giving a third parameter
<code><count
></code>, you can limit the output to
976 the first
<code><count
></code> lines, followed by
<code>...
</code> if there are more.
978 <div class=
"paragraph"><p>These parameters can also be set individually with
<code>--stat-width=
<width
></code>,
979 <code>--stat-name-width=
<name-width
></code> and
<code>--stat-count=
<count
></code>.
</p></div>
986 Output a condensed summary of extended header information such
987 as file creations or deletions (
"new" or
"gone", optionally
"+l"
988 if it
’s a symlink) and mode changes (
"+x" or
"-x" for adding
989 or removing executable bit respectively) in diffstat. The
990 information is put between the filename part and the graph
991 part. Implies
<code>--stat
</code>.
999 Similar to
<code>--stat
</code>, but shows number of added and
1000 deleted lines in decimal notation and pathname without
1001 abbreviation, to make it more machine friendly. For
1002 binary files, outputs two
<code>-
</code> instead of saying
1006 <dt class=
"hdlist1">
1011 Output only the last line of the
<code>--stat
</code> format containing total
1012 number of modified files, as well as number of added and deleted
1016 <dt class=
"hdlist1">
1017 -X[
<param1,param2,
…>]
1019 <dt class=
"hdlist1">
1020 --dirstat[=
<param1,param2,
…>]
1024 Output the distribution of relative amount of changes for each
1025 sub-directory. The behavior of
<code>--dirstat
</code> can be customized by
1026 passing it a comma separated list of parameters.
1027 The defaults are controlled by the
<code>diff.dirstat
</code> configuration
1028 variable (see
<a href=
"git-config.html">git-config(
1)
</a>).
1029 The following parameters are available:
1031 <div class=
"openblock">
1032 <div class=
"content">
1033 <div class=
"dlist"><dl>
1034 <dt class=
"hdlist1">
1035 <code>changes
</code>
1039 Compute the dirstat numbers by counting the lines that have been
1040 removed from the source, or added to the destination. This ignores
1041 the amount of pure code movements within a file. In other words,
1042 rearranging lines in a file is not counted as much as other changes.
1043 This is the default behavior when no parameter is given.
1046 <dt class=
"hdlist1">
1051 Compute the dirstat numbers by doing the regular line-based diff
1052 analysis, and summing the removed/added line counts. (For binary
1053 files, count
64-byte chunks instead, since binary files have no
1054 natural concept of lines). This is a more expensive
<code>--dirstat
</code>
1055 behavior than the
<code>changes
</code> behavior, but it does count rearranged
1056 lines within a file as much as other changes. The resulting output
1057 is consistent with what you get from the other
<code>--*stat
</code> options.
1060 <dt class=
"hdlist1">
1065 Compute the dirstat numbers by counting the number of files changed.
1066 Each changed file counts equally in the dirstat analysis. This is
1067 the computationally cheapest
<code>--dirstat
</code> behavior, since it does
1068 not have to look at the file contents at all.
1071 <dt class=
"hdlist1">
1072 <code>cumulative
</code>
1076 Count changes in a child directory for the parent directory as well.
1077 Note that when using
<code>cumulative
</code>, the sum of the percentages
1078 reported may exceed
100%. The default (non-cumulative) behavior can
1079 be specified with the
<code>noncumulative
</code> parameter.
1082 <dt class=
"hdlist1">
1087 An integer parameter specifies a cut-off percent (
3% by default).
1088 Directories contributing less than this percentage of the changes
1089 are not shown in the output.
1094 <div class=
"paragraph"><p>Example: The following will count changed files, while ignoring
1095 directories with less than
10% of the total amount of changed files,
1096 and accumulating child directory counts in the parent directories:
1097 <code>--dirstat=files,
10,cumulative
</code>.
</p></div>
1099 <dt class=
"hdlist1">
1104 Synonym for --dirstat=cumulative
1107 <dt class=
"hdlist1">
1108 --dirstat-by-file[=
<param1,param2
>…]
1112 Synonym for --dirstat=files,
<param1
>,
<param2
>…
1115 <dt class=
"hdlist1">
1120 Output a condensed summary of extended header information
1121 such as creations, renames and mode changes.
1124 <dt class=
"hdlist1">
1129 Synonym for
<code>-p --stat
</code>.
1132 <dt class=
"hdlist1">
1137 When
<code>--raw
</code>,
<code>--numstat
</code>,
<code>--name-only
</code> or
<code>--name-status
</code> has been
1138 given, do not munge pathnames and use NULs as output field terminators.
1140 <div class=
"paragraph"><p>Without this option, pathnames with
"unusual" characters are quoted as
1141 explained for the configuration variable
<code>core.quotePath
</code> (see
1142 <a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
1144 <dt class=
"hdlist1">
1149 Show only names of changed files. The file names are often encoded in UTF-
8.
1150 For more information see the discussion about encoding in the
<a href=
"git-log.html">git-log(
1)
</a>
1154 <dt class=
"hdlist1">
1159 Show only names and status of changed files. See the description
1160 of the
<code>--diff-filter
</code> option on what the status letters mean.
1161 Just like
<code>--name-only
</code> the file names are often encoded in UTF-
8.
1164 <dt class=
"hdlist1">
1165 --submodule[=
<format
>]
1169 Specify how differences in submodules are shown. When specifying
1170 <code>--submodule=short
</code> the
<em>short
</em> format is used. This format just
1171 shows the names of the commits at the beginning and end of the range.
1172 When
<code>--submodule
</code> or
<code>--submodule=log
</code> is specified, the
<em>log
</em>
1173 format is used. This format lists the commits in the range like
1174 <a href=
"git-submodule.html">git-submodule(
1)
</a> <code>summary
</code> does. When
<code>--submodule=diff
</code>
1175 is specified, the
<em>diff
</em> format is used. This format shows an
1176 inline diff of the changes in the submodule contents between the
1177 commit range. Defaults to
<code>diff.submodule
</code> or the
<em>short
</em> format
1178 if the config option is unset.
1181 <dt class=
"hdlist1">
1182 --color[=
<when
>]
1187 <code>--color
</code> (i.e. without
<em>=
<when
></em>) is the same as
<code>--color=always
</code>.
1188 <em><when
></em> can be one of
<code>always
</code>,
<code>never
</code>, or
<code>auto
</code>.
1191 <dt class=
"hdlist1">
1196 Turn off colored diff.
1197 It is the same as
<code>--color=never
</code>.
1200 <dt class=
"hdlist1">
1201 --color-moved[=
<mode
>]
1205 Moved lines of code are colored differently.
1206 The
<mode
> defaults to
<em>no
</em> if the option is not given
1207 and to
<em>zebra
</em> if the option with no mode is given.
1208 The mode must be one of:
1210 <div class=
"openblock">
1211 <div class=
"content">
1212 <div class=
"dlist"><dl>
1213 <dt class=
"hdlist1">
1218 Moved lines are not highlighted.
1221 <dt class=
"hdlist1">
1226 Is a synonym for
<code>zebra
</code>. This may change to a more sensible mode
1230 <dt class=
"hdlist1">
1235 Any line that is added in one location and was removed
1236 in another location will be colored with
<em>color.diff.newMoved
</em>.
1237 Similarly
<em>color.diff.oldMoved
</em> will be used for removed lines
1238 that are added somewhere else in the diff. This mode picks up any
1239 moved line, but it is not very useful in a review to determine
1240 if a block of code was moved without permutation.
1243 <dt class=
"hdlist1">
1248 Blocks of moved text of at least
20 alphanumeric characters
1249 are detected greedily. The detected blocks are
1250 painted using either the
<em>color.diff.{old,new}Moved
</em> color.
1251 Adjacent blocks cannot be told apart.
1254 <dt class=
"hdlist1">
1259 Blocks of moved text are detected as in
<em>blocks
</em> mode. The blocks
1260 are painted using either the
<em>color.diff.{old,new}Moved
</em> color or
1261 <em>color.diff.{old,new}MovedAlternative
</em>. The change between
1262 the two colors indicates that a new block was detected.
1265 <dt class=
"hdlist1">
1270 Similar to
<em>zebra
</em>, but additional dimming of uninteresting parts
1271 of moved code is performed. The bordering lines of two adjacent
1272 blocks are considered interesting, the rest is uninteresting.
1273 <code>dimmed_zebra
</code> is a deprecated synonym.
1279 <dt class=
"hdlist1">
1284 Turn off move detection. This can be used to override configuration
1285 settings. It is the same as
<code>--color-moved=no
</code>.
1288 <dt class=
"hdlist1">
1289 --color-moved-ws=
<modes
>
1293 This configures how whitespace is ignored when performing the
1294 move detection for
<code>--color-moved
</code>.
1295 These modes can be given as a comma separated list:
1297 <div class=
"openblock">
1298 <div class=
"content">
1299 <div class=
"dlist"><dl>
1300 <dt class=
"hdlist1">
1305 Do not ignore whitespace when performing move detection.
1308 <dt class=
"hdlist1">
1313 Ignore changes in whitespace at EOL.
1316 <dt class=
"hdlist1">
1321 Ignore changes in amount of whitespace. This ignores whitespace
1322 at line end, and considers all other sequences of one or
1323 more whitespace characters to be equivalent.
1326 <dt class=
"hdlist1">
1331 Ignore whitespace when comparing lines. This ignores differences
1332 even if one line has whitespace where the other line has none.
1335 <dt class=
"hdlist1">
1336 allow-indentation-change
1340 Initially ignore any whitespace in the move detection, then
1341 group the moved code blocks only into a block if the change in
1342 whitespace is the same per line. This is incompatible with the
1349 <dt class=
"hdlist1">
1354 Do not ignore whitespace when performing move detection. This can be
1355 used to override configuration settings. It is the same as
1356 <code>--color-moved-ws=no
</code>.
1359 <dt class=
"hdlist1">
1360 --word-diff[=
<mode
>]
1364 Show a word diff, using the
<mode
> to delimit changed words.
1365 By default, words are delimited by whitespace; see
1366 <code>--word-diff-regex
</code> below. The
<mode
> defaults to
<em>plain
</em>, and
1369 <div class=
"openblock">
1370 <div class=
"content">
1371 <div class=
"dlist"><dl>
1372 <dt class=
"hdlist1">
1377 Highlight changed words using only colors. Implies
<code>--color
</code>.
1380 <dt class=
"hdlist1">
1385 Show words as
<code>[-removed-]
</code> and
<code>{+added+}
</code>. Makes no
1386 attempts to escape the delimiters if they appear in the input,
1387 so the output may be ambiguous.
1390 <dt class=
"hdlist1">
1395 Use a special line-based format intended for script
1396 consumption. Added/removed/unchanged runs are printed in the
1397 usual unified diff format, starting with a
<code>+
</code>/
<code>-
</code>/` `
1398 character at the beginning of the line and extending to the
1399 end of the line. Newlines in the input are represented by a
1400 tilde
<code>~
</code> on a line of its own.
1403 <dt class=
"hdlist1">
1408 Disable word diff again.
1413 <div class=
"paragraph"><p>Note that despite the name of the first mode, color is used to
1414 highlight the changed parts in all modes if enabled.
</p></div>
1416 <dt class=
"hdlist1">
1417 --word-diff-regex=
<regex
>
1421 Use
<regex
> to decide what a word is, instead of considering
1422 runs of non-whitespace to be a word. Also implies
1423 <code>--word-diff
</code> unless it was already enabled.
1425 <div class=
"paragraph"><p>Every non-overlapping match of the
1426 <regex
> is considered a word. Anything between these matches is
1427 considered whitespace and ignored(!) for the purposes of finding
1428 differences. You may want to append
<code>|[^[:space:]]
</code> to your regular
1429 expression to make sure that it matches all non-whitespace characters.
1430 A match that contains a newline is silently truncated(!) at the
1432 <div class=
"paragraph"><p>For example,
<code>--word-diff-regex=.
</code> will treat each character as a word
1433 and, correspondingly, show differences character by character.
</p></div>
1434 <div class=
"paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1435 <a href=
"gitattributes.html">gitattributes(
5)
</a> or
<a href=
"git-config.html">git-config(
1)
</a>. Giving it explicitly
1436 overrides any diff driver or configuration setting. Diff drivers
1437 override configuration settings.
</p></div>
1439 <dt class=
"hdlist1">
1440 --color-words[=
<regex
>]
1444 Equivalent to
<code>--word-diff=color
</code> plus (if a regex was
1445 specified)
<code>--word-diff-regex=
<regex
></code>.
1448 <dt class=
"hdlist1">
1453 Turn off rename detection, even when the configuration
1454 file gives the default to do so.
1457 <dt class=
"hdlist1">
1462 Whether to use empty blobs as rename source.
1465 <dt class=
"hdlist1">
1470 Warn if changes introduce conflict markers or whitespace errors.
1471 What are considered whitespace errors is controlled by
<code>core.whitespace
</code>
1472 configuration. By default, trailing whitespaces (including
1473 lines that consist solely of whitespaces) and a space character
1474 that is immediately followed by a tab character inside the
1475 initial indent of the line are considered whitespace errors.
1476 Exits with non-zero status if problems are found. Not compatible
1480 <dt class=
"hdlist1">
1481 --ws-error-highlight=
<kind
>
1485 Highlight whitespace errors in the
<code>context
</code>,
<code>old
</code> or
<code>new
</code>
1486 lines of the diff. Multiple values are separated by comma,
1487 <code>none
</code> resets previous values,
<code>default
</code> reset the list to
1488 <code>new
</code> and
<code>all
</code> is a shorthand for
<code>old,new,context
</code>. When
1489 this option is not given, and the configuration variable
1490 <code>diff.wsErrorHighlight
</code> is not set, only whitespace errors in
1491 <code>new
</code> lines are highlighted. The whitespace errors are colored
1492 with
<code>color.diff.whitespace
</code>.
1495 <dt class=
"hdlist1">
1500 Instead of the first handful of characters, show the full
1501 pre- and post-image blob object names on the
"index"
1502 line when generating patch format output.
1505 <dt class=
"hdlist1">
1510 In addition to
<code>--full-index
</code>, output a binary diff that
1511 can be applied with
<code>git-apply
</code>.
1512 Implies
<code>--patch
</code>.
1515 <dt class=
"hdlist1">
1516 --abbrev[=
<n
>]
1520 Instead of showing the full
40-byte hexadecimal object
1521 name in diff-raw format output and diff-tree header
1522 lines, show the shortest prefix that is at least
<em><n
></em>
1523 hexdigits long that uniquely refers the object.
1524 In diff-patch output format,
<code>--full-index
</code> takes higher
1525 precedence, i.e. if
<code>--full-index
</code> is specified, full blob
1526 names will be shown regardless of
<code>--abbrev
</code>.
1527 Non default number of digits can be specified with
<code>--abbrev=
<n
></code>.
1530 <dt class=
"hdlist1">
1531 -B[
<n
>][/
<m
>]
1533 <dt class=
"hdlist1">
1534 --break-rewrites[=[
<n
>][/
<m
>]]
1538 Break complete rewrite changes into pairs of delete and
1539 create. This serves two purposes:
1541 <div class=
"paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1542 not as a series of deletion and insertion mixed together with a very
1543 few lines that happen to match textually as the context, but as a
1544 single deletion of everything old followed by a single insertion of
1545 everything new, and the number
<code>m
</code> controls this aspect of the -B
1546 option (defaults to
60%).
<code>-B/
70%
</code> specifies that less than
30% of the
1547 original should remain in the result for Git to consider it a total
1548 rewrite (i.e. otherwise the resulting patch will be a series of
1549 deletion and insertion mixed together with context lines).
</p></div>
1550 <div class=
"paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1551 source of a rename (usually -M only considers a file that disappeared
1552 as the source of a rename), and the number
<code>n
</code> controls this aspect of
1553 the -B option (defaults to
50%).
<code>-B20%
</code> specifies that a change with
1554 addition and deletion compared to
20% or more of the file
’s size are
1555 eligible for being picked up as a possible source of a rename to
1556 another file.
</p></div>
1558 <dt class=
"hdlist1">
1561 <dt class=
"hdlist1">
1562 --find-renames[=
<n
>]
1567 If
<code>n
</code> is specified, it is a threshold on the similarity
1568 index (i.e. amount of addition/deletions compared to the
1569 file
’s size). For example,
<code>-M90%
</code> means Git should consider a
1570 delete/add pair to be a rename if more than
90% of the file
1571 hasn
’t changed. Without a
<code>%
</code> sign, the number is to be read as
1572 a fraction, with a decimal point before it. I.e.,
<code>-M5
</code> becomes
1573 0.5, and is thus the same as
<code>-M50%
</code>. Similarly,
<code>-M05
</code> is
1574 the same as
<code>-M5%
</code>. To limit detection to exact renames, use
1575 <code>-M100%
</code>. The default similarity index is
50%.
1578 <dt class=
"hdlist1">
1581 <dt class=
"hdlist1">
1582 --find-copies[=
<n
>]
1586 Detect copies as well as renames. See also
<code>--find-copies-harder
</code>.
1587 If
<code>n
</code> is specified, it has the same meaning as for
<code>-M
<n
></code>.
1590 <dt class=
"hdlist1">
1591 --find-copies-harder
1595 For performance reasons, by default,
<code>-C
</code> option finds copies only
1596 if the original file of the copy was modified in the same
1597 changeset. This flag makes the command
1598 inspect unmodified files as candidates for the source of
1599 copy. This is a very expensive operation for large
1600 projects, so use it with caution. Giving more than one
1601 <code>-C
</code> option has the same effect.
1604 <dt class=
"hdlist1">
1607 <dt class=
"hdlist1">
1608 --irreversible-delete
1612 Omit the preimage for deletes, i.e. print only the header but not
1613 the diff between the preimage and
<code>/dev/null
</code>. The resulting patch
1614 is not meant to be applied with
<code>patch
</code> or
<code>git apply
</code>; this is
1615 solely for people who want to just concentrate on reviewing the
1616 text after the change. In addition, the output obviously lacks
1617 enough information to apply such a patch in reverse, even manually,
1618 hence the name of the option.
1620 <div class=
"paragraph"><p>When used together with
<code>-B
</code>, omit also the preimage in the deletion part
1621 of a delete/create pair.
</p></div>
1623 <dt class=
"hdlist1">
1628 The
<code>-M
</code> and
<code>-C
</code> options involve some preliminary steps that
1629 can detect subsets of renames/copies cheaply, followed by an
1630 exhaustive fallback portion that compares all remaining
1631 unpaired destinations to all relevant sources. (For renames,
1632 only remaining unpaired sources are relevant; for copies, all
1633 original sources are relevant.) For N sources and
1634 destinations, this exhaustive check is O(N^
2). This option
1635 prevents the exhaustive portion of rename/copy detection from
1636 running if the number of source/destination files involved
1637 exceeds the specified number. Defaults to diff.renameLimit.
1638 Note that a value of
0 is treated as unlimited.
1641 <dt class=
"hdlist1">
1642 --diff-filter=[(A|C|D|M|R|T|U|X|B)
…[*]]
1646 Select only files that are Added (
<code>A
</code>), Copied (
<code>C
</code>),
1647 Deleted (
<code>D
</code>), Modified (
<code>M
</code>), Renamed (
<code>R
</code>), have their
1648 type (i.e. regular file, symlink, submodule,
…) changed (
<code>T
</code>),
1649 are Unmerged (
<code>U
</code>), are
1650 Unknown (
<code>X
</code>), or have had their pairing Broken (
<code>B
</code>).
1651 Any combination of the filter characters (including none) can be used.
1652 When
<code>*
</code> (All-or-none) is added to the combination, all
1653 paths are selected if there is any file that matches
1654 other criteria in the comparison; if there is no file
1655 that matches other criteria, nothing is selected.
1657 <div class=
"paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1658 <code>--diff-filter=ad
</code> excludes added and deleted paths.
</p></div>
1659 <div class=
"paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
1660 renamed entries cannot appear if detection for those types is disabled.
</p></div>
1662 <dt class=
"hdlist1">
1667 Look for differences that change the number of occurrences of
1668 the specified string (i.e. addition/deletion) in a file.
1669 Intended for the scripter
’s use.
1671 <div class=
"paragraph"><p>It is useful when you
’re looking for an exact block of code (like a
1672 struct), and want to know the history of that block since it first
1673 came into being: use the feature iteratively to feed the interesting
1674 block in the preimage back into
<code>-S
</code>, and keep going until you get the
1675 very first version of the block.
</p></div>
1676 <div class=
"paragraph"><p>Binary files are searched as well.
</p></div>
1678 <dt class=
"hdlist1">
1683 Look for differences whose patch text contains added/removed
1684 lines that match
<regex
>.
1686 <div class=
"paragraph"><p>To illustrate the difference between
<code>-S
<regex
> --pickaxe-regex
</code> and
1687 <code>-G
<regex
></code>, consider a commit with the following diff in the same
1689 <div class=
"listingblock">
1690 <div class=
"content">
1691 <pre><code>+ return frotz(nitfol, two-
>ptr,
1,
0);
1693 - hit = frotz(nitfol, mf2.ptr,
1,
0);
</code></pre>
1695 <div class=
"paragraph"><p>While
<code>git log -G
"frotz\(nitfol"</code> will show this commit,
<code>git log
1696 -S
"frotz\(nitfol" --pickaxe-regex
</code> will not (because the number of
1697 occurrences of that string did not change).
</p></div>
1698 <div class=
"paragraph"><p>Unless
<code>--text
</code> is supplied patches of binary files without a textconv
1699 filter will be ignored.
</p></div>
1700 <div class=
"paragraph"><p>See the
<em>pickaxe
</em> entry in
<a href=
"gitdiffcore.html">gitdiffcore(
7)
</a> for more
1701 information.
</p></div>
1703 <dt class=
"hdlist1">
1704 --find-object=
<object-id
>
1708 Look for differences that change the number of occurrences of
1709 the specified object. Similar to
<code>-S
</code>, just the argument is different
1710 in that it doesn
’t search for a specific string but for a specific
1713 <div class=
"paragraph"><p>The object can be a blob or a submodule commit. It implies the
<code>-t
</code> option in
1714 <code>git-log
</code> to also find trees.
</p></div>
1716 <dt class=
"hdlist1">
1721 When
<code>-S
</code> or
<code>-G
</code> finds a change, show all the changes in that
1722 changeset, not just the files that contain the change
1726 <dt class=
"hdlist1">
1731 Treat the
<string
> given to
<code>-S
</code> as an extended POSIX regular
1732 expression to match.
1735 <dt class=
"hdlist1">
1740 Control the order in which files appear in the output.
1741 This overrides the
<code>diff.orderFile
</code> configuration variable
1742 (see
<a href=
"git-config.html">git-config(
1)
</a>). To cancel
<code>diff.orderFile
</code>,
1743 use
<code>-O/dev/null
</code>.
1745 <div class=
"paragraph"><p>The output order is determined by the order of glob patterns in
1747 All files with pathnames that match the first pattern are output
1748 first, all files with pathnames that match the second pattern (but not
1749 the first) are output next, and so on.
1750 All files with pathnames that do not match any pattern are output
1751 last, as if there was an implicit match-all pattern at the end of the
1753 If multiple pathnames have the same rank (they match the same pattern
1754 but no earlier patterns), their output order relative to each other is
1755 the normal order.
</p></div>
1756 <div class=
"paragraph"><p><orderfile
> is parsed as follows:
</p></div>
1757 <div class=
"openblock">
1758 <div class=
"content">
1759 <div class=
"ulist"><ul>
1762 Blank lines are ignored, so they can be used as separators for
1768 Lines starting with a hash (
"<code>#</code>") are ignored, so they can be used
1769 for comments. Add a backslash (
"<code>\</code>") to the beginning of the
1770 pattern if it starts with a hash.
1775 Each other line contains a single pattern.
1780 <div class=
"paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1781 fnmatch(
3) without the FNM_PATHNAME flag, except a pathname also
1782 matches a pattern if removing any number of the final pathname
1783 components matches the pattern. For example, the pattern
"<code>foo*bar</code>"
1784 matches
"<code>fooasdfbar</code>" and
"<code>foo/bar/baz/asdf</code>" but not
"<code>foobarx</code>".
</p></div>
1786 <dt class=
"hdlist1">
1787 --skip-to=
<file
>
1789 <dt class=
"hdlist1">
1790 --rotate-to=
<file
>
1794 Discard the files before the named
<file
> from the output
1795 (i.e.
<em>skip to
</em>), or move them to the end of the output
1796 (i.e.
<em>rotate to
</em>). These options were invented primarily for the use
1797 of the
<code>git difftool
</code> command, and may not be very useful
1801 <dt class=
"hdlist1">
1806 Swap two inputs; that is, show differences from index or
1807 on-disk file to tree contents.
1810 <dt class=
"hdlist1">
1811 --relative[=
<path
>]
1813 <dt class=
"hdlist1">
1818 When run from a subdirectory of the project, it can be
1819 told to exclude changes outside the directory and show
1820 pathnames relative to it with this option. When you are
1821 not in a subdirectory (e.g. in a bare repository), you
1822 can name which subdirectory to make the output relative
1823 to by giving a
<path
> as an argument.
1824 <code>--no-relative
</code> can be used to countermand both
<code>diff.relative
</code> config
1825 option and previous
<code>--relative
</code>.
1828 <dt class=
"hdlist1">
1831 <dt class=
"hdlist1">
1836 Treat all files as text.
1839 <dt class=
"hdlist1">
1844 Ignore carriage-return at the end of line when doing a comparison.
1847 <dt class=
"hdlist1">
1848 --ignore-space-at-eol
1852 Ignore changes in whitespace at EOL.
1855 <dt class=
"hdlist1">
1858 <dt class=
"hdlist1">
1859 --ignore-space-change
1863 Ignore changes in amount of whitespace. This ignores whitespace
1864 at line end, and considers all other sequences of one or
1865 more whitespace characters to be equivalent.
1868 <dt class=
"hdlist1">
1871 <dt class=
"hdlist1">
1876 Ignore whitespace when comparing lines. This ignores
1877 differences even if one line has whitespace where the other
1881 <dt class=
"hdlist1">
1882 --ignore-blank-lines
1886 Ignore changes whose lines are all blank.
1889 <dt class=
"hdlist1">
1892 <dt class=
"hdlist1">
1893 --ignore-matching-lines=
<regex
>
1897 Ignore changes whose all lines match
<regex
>. This option may
1898 be specified more than once.
1901 <dt class=
"hdlist1">
1902 --inter-hunk-context=
<lines
>
1906 Show the context between diff hunks, up to the specified number
1907 of lines, thereby fusing hunks that are close to each other.
1908 Defaults to
<code>diff.interHunkContext
</code> or
0 if the config option
1912 <dt class=
"hdlist1">
1915 <dt class=
"hdlist1">
1920 Show whole function as context lines for each change.
1921 The function names are determined in the same way as
1922 <code>git diff
</code> works out patch hunk headers (see
<em>Defining a
1923 custom hunk-header
</em> in
<a href=
"gitattributes.html">gitattributes(
5)
</a>).
1926 <dt class=
"hdlist1">
1931 Make the program exit with codes similar to diff(
1).
1932 That is, it exits with
1 if there were differences and
1933 0 means no differences.
1936 <dt class=
"hdlist1">
1941 Disable all output of the program. Implies
<code>--exit-code
</code>.
1944 <dt class=
"hdlist1">
1949 Allow an external diff helper to be executed. If you set an
1950 external diff driver with
<a href=
"gitattributes.html">gitattributes(
5)
</a>, you need
1951 to use this option with
<a href=
"git-log.html">git-log(
1)
</a> and friends.
1954 <dt class=
"hdlist1">
1959 Disallow external diff drivers.
1962 <dt class=
"hdlist1">
1965 <dt class=
"hdlist1">
1970 Allow (or disallow) external text conversion filters to be run
1971 when comparing binary files. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for
1972 details. Because textconv filters are typically a one-way
1973 conversion, the resulting diff is suitable for human
1974 consumption, but cannot be applied. For this reason, textconv
1975 filters are enabled by default only for
<a href=
"git-diff.html">git-diff(
1)
</a> and
1976 <a href=
"git-log.html">git-log(
1)
</a>, but not for
<a href=
"git-format-patch.html">git-format-patch(
1)
</a> or
1977 diff plumbing commands.
1980 <dt class=
"hdlist1">
1981 --ignore-submodules[=
<when
>]
1985 Ignore changes to submodules in the diff generation.
<when
> can be
1986 either
"none",
"untracked",
"dirty" or
"all", which is the default.
1987 Using
"none" will consider the submodule modified when it either contains
1988 untracked or modified files or its HEAD differs from the commit recorded
1989 in the superproject and can be used to override any settings of the
1990 <em>ignore
</em> option in
<a href=
"git-config.html">git-config(
1)
</a> or
<a href=
"gitmodules.html">gitmodules(
5)
</a>. When
1991 "untracked" is used submodules are not considered dirty when they only
1992 contain untracked content (but they are still scanned for modified
1993 content). Using
"dirty" ignores all changes to the work tree of submodules,
1994 only changes to the commits stored in the superproject are shown (this was
1995 the behavior until
1.7.0). Using
"all" hides all changes to submodules.
1998 <dt class=
"hdlist1">
1999 --src-prefix=
<prefix
>
2003 Show the given source prefix instead of
"a/".
2006 <dt class=
"hdlist1">
2007 --dst-prefix=
<prefix
>
2011 Show the given destination prefix instead of
"b/".
2014 <dt class=
"hdlist1">
2019 Do not show any source or destination prefix.
2022 <dt class=
"hdlist1">
2027 Use the default source and destination prefixes (
"a/" and
"b/").
2028 This is usually the default already, but may be used to override
2029 config such as
<code>diff.noprefix
</code>.
2032 <dt class=
"hdlist1">
2033 --line-prefix=
<prefix
>
2037 Prepend an additional prefix to every line of output.
2040 <dt class=
"hdlist1">
2041 --ita-invisible-in-index
2045 By default entries added by
"git add -N" appear as an existing
2046 empty file in
"git diff" and a new file in
"git diff --cached".
2047 This option makes the entry appear as a new file in
"git diff"
2048 and non-existent in
"git diff --cached". This option could be
2049 reverted with
<code>--ita-visible-in-index
</code>. Both options are
2050 experimental and could be removed in future.
2054 <div class=
"paragraph"><p>For more detailed explanation on these common options, see also
2055 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a>.
</p></div>
2056 <div class=
"dlist"><dl>
2057 <dt class=
"hdlist1">
2062 The id of a tree object to diff against.
2065 <dt class=
"hdlist1">
2070 Do not consider the on-disk file at all.
2073 <dt class=
"hdlist1">
2078 Instead of comparing
<tree-ish
> directly, use the merge base
2079 between
<tree-ish
> and HEAD instead.
<tree-ish
> must be a
2083 <dt class=
"hdlist1">
2088 By default, files recorded in the index but not checked
2089 out are reported as deleted. This flag makes
2090 <em>git diff-index
</em> say that all non-checked-out files are up
2098 <h2 id=
"_raw_output_format">Raw output format
</h2>
2099 <div class=
"sectionbody">
2100 <div class=
"paragraph"><p>The raw output format from
"git-diff-index",
"git-diff-tree",
2101 "git-diff-files" and
"git diff --raw" are very similar.
</p></div>
2102 <div class=
"paragraph"><p>These commands all compare two sets of things; what is
2103 compared differs:
</p></div>
2104 <div class=
"dlist"><dl>
2105 <dt class=
"hdlist1">
2106 git-diff-index
<tree-ish
>
2110 compares the
<tree-ish
> and the files on the filesystem.
2113 <dt class=
"hdlist1">
2114 git-diff-index --cached
<tree-ish
>
2118 compares the
<tree-ish
> and the index.
2121 <dt class=
"hdlist1">
2122 git-diff-tree [-r]
<tree-ish-
1> <tree-ish-
2> [
<pattern
>…]
2126 compares the trees named by the two arguments.
2129 <dt class=
"hdlist1">
2130 git-diff-files [
<pattern
>…]
2134 compares the index and the files on the filesystem.
2138 <div class=
"paragraph"><p>The
"git-diff-tree" command begins its output by printing the hash of
2139 what is being compared. After that, all the commands print one output
2140 line per changed file.
</p></div>
2141 <div class=
"paragraph"><p>An output line is formatted this way:
</p></div>
2142 <div class=
"listingblock">
2143 <div class=
"content">
2144 <pre><code>in-place edit :
100644 100644 bcd1234
0123456 M file0
2145 copy-edit :
100644 100644 abcd123
1234567 C68 file1 file2
2146 rename-edit :
100644 100644 abcd123
1234567 R86 file1 file3
2147 create :
000000 100644 0000000 1234567 A file4
2148 delete :
100644 000000 1234567 0000000 D file5
2149 unmerged :
000000 000000 0000000 0000000 U file6
</code></pre>
2151 <div class=
"paragraph"><p>That is, from the left to the right:
</p></div>
2152 <div class=
"olist arabic"><ol class=
"arabic">
2160 mode for
"src";
000000 if creation or unmerged.
2170 mode for
"dst";
000000 if deletion or unmerged.
2180 sha1 for
"src";
0{
40} if creation or unmerged.
2190 sha1 for
"dst";
0{
40} if deletion, unmerged or
"work tree out of sync with the index".
2200 status, followed by optional
"score" number.
2205 a tab or a NUL when
<code>-z
</code> option is used.
2215 a tab or a NUL when
<code>-z
</code> option is used; only exists for C or R.
2220 path for
"dst"; only exists for C or R.
2225 an LF or a NUL when
<code>-z
</code> option is used, to terminate the record.
2229 <div class=
"paragraph"><p>Possible status letters are:
</p></div>
2230 <div class=
"ulist"><ul>
2233 A: addition of a file
2238 C: copy of a file into a new one
2243 D: deletion of a file
2248 M: modification of the contents or mode of a file
2253 R: renaming of a file
2258 T: change in the type of the file (regular file, symbolic link or submodule)
2263 U: file is unmerged (you must complete the merge before it can
2269 X:
"unknown" change type (most probably a bug, please report it)
2273 <div class=
"paragraph"><p>Status letters C and R are always followed by a score (denoting the
2274 percentage of similarity between the source and target of the move or
2275 copy). Status letter M may be followed by a score (denoting the
2276 percentage of dissimilarity) for file rewrites.
</p></div>
2277 <div class=
"paragraph"><p>The sha1 for
"dst" is shown as all
0’s if a file on the filesystem
2278 is out of sync with the index.
</p></div>
2279 <div class=
"paragraph"><p>Example:
</p></div>
2280 <div class=
"listingblock">
2281 <div class=
"content">
2282 <pre><code>:
100644 100644 5be4a4a
0000000 M file.c
</code></pre>
2284 <div class=
"paragraph"><p>Without the
<code>-z
</code> option, pathnames with
"unusual" characters are
2285 quoted as explained for the configuration variable
<code>core.quotePath
</code>
2286 (see
<a href=
"git-config.html">git-config(
1)
</a>). Using
<code>-z
</code> the filename is output
2287 verbatim and the line is terminated by a NUL byte.
</p></div>
2291 <h2 id=
"_diff_format_for_merges">diff format for merges
</h2>
2292 <div class=
"sectionbody">
2293 <div class=
"paragraph"><p>"git-diff-tree",
"git-diff-files" and
"git-diff --raw"
2294 can take
<code>-c
</code> or
<code>--cc
</code> option
2295 to generate diff output also for merge commits. The output differs
2296 from the format described above in the following way:
</p></div>
2297 <div class=
"olist arabic"><ol class=
"arabic">
2300 there is a colon for each parent
2305 there are more
"src" modes and
"src" sha1
2310 status is concatenated status characters for each parent
2315 no optional
"score" number
2320 tab-separated pathname(s) of the file
2324 <div class=
"paragraph"><p>For
<code>-c
</code> and
<code>--cc
</code>, only the destination or final path is shown even
2325 if the file was renamed on any side of history. With
2326 <code>--combined-all-paths
</code>, the name of the path in each parent is shown
2327 followed by the name of the path in the merge commit.
</p></div>
2328 <div class=
"paragraph"><p>Examples for
<code>-c
</code> and
<code>--cc
</code> without
<code>--combined-all-paths
</code>:
</p></div>
2329 <div class=
"listingblock">
2330 <div class=
"content">
2331 <pre><code>::
100644 100644 100644 fabadb8 cc95eb0
4866510 MM desc.c
2332 ::
100755 100755 100755 52b7a2d
6d1ac04 d2ac7d7 RM bar.sh
2333 ::
100644 100644 100644 e07d6c5
9042e82 ee91881 RR phooey.c
</code></pre>
2335 <div class=
"paragraph"><p>Examples when
<code>--combined-all-paths
</code> added to either
<code>-c
</code> or
<code>--cc
</code>:
</p></div>
2336 <div class=
"listingblock">
2337 <div class=
"content">
2338 <pre><code>::
100644 100644 100644 fabadb8 cc95eb0
4866510 MM desc.c desc.c desc.c
2339 ::
100755 100755 100755 52b7a2d
6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
2340 ::
100644 100644 100644 e07d6c5
9042e82 ee91881 RR fooey.c fuey.c phooey.c
</code></pre>
2342 <div class=
"paragraph"><p>Note that
<em>combined diff
</em> lists only files which were modified from
2343 all parents.
</p></div>
2347 <h2 id=
"generate_patch_text_with_p">Generating patch text with -p
</h2>
2348 <div class=
"sectionbody">
2349 <div class=
"paragraph"><p>Running
2350 <a href=
"git-diff.html">git-diff(
1)
</a>,
2351 <a href=
"git-log.html">git-log(
1)
</a>,
2352 <a href=
"git-show.html">git-show(
1)
</a>,
2353 <a href=
"git-diff-index.html">git-diff-index(
1)
</a>,
2354 <a href=
"git-diff-tree.html">git-diff-tree(
1)
</a>, or
2355 <a href=
"git-diff-files.html">git-diff-files(
1)
</a>
2356 with the
<code>-p
</code> option produces patch text.
2357 You can customize the creation of patch text via the
2358 <code>GIT_EXTERNAL_DIFF
</code> and the
<code>GIT_DIFF_OPTS
</code> environment variables
2359 (see
<a href=
"git.html">git(
1)
</a>), and the
<code>diff
</code> attribute (see
<a href=
"gitattributes.html">gitattributes(
5)
</a>).
</p></div>
2360 <div class=
"paragraph"><p>What the -p option produces is slightly different from the traditional
2361 diff format:
</p></div>
2362 <div class=
"olist arabic"><ol class=
"arabic">
2365 It is preceded by a
"git diff" header that looks like this:
2367 <div class=
"literalblock">
2368 <div class=
"content">
2369 <pre><code>diff --git a/file1 b/file2
</code></pre>
2371 <div class=
"paragraph"><p>The
<code>a/
</code> and
<code>b/
</code> filenames are the same unless rename/copy is
2372 involved. Especially, even for a creation or a deletion,
2373 <code>/dev/null
</code> is
<em>not
</em> used in place of the
<code>a/
</code> or
<code>b/
</code> filenames.
</p></div>
2374 <div class=
"paragraph"><p>When a rename/copy is involved,
<code>file1
</code> and
<code>file2
</code> show the
2375 name of the source file of the rename/copy and the name of
2376 the file that the rename/copy produces, respectively.
</p></div>
2380 It is followed by one or more extended header lines:
2382 <div class=
"literalblock">
2383 <div class=
"content">
2384 <pre><code>old mode
<mode
>
2385 new mode
<mode
>
2386 deleted file mode
<mode
>
2387 new file mode
<mode
>
2388 copy from
<path
>
2389 copy to
<path
>
2390 rename from
<path
>
2391 rename to
<path
>
2392 similarity index
<number
>
2393 dissimilarity index
<number
>
2394 index
<hash
>..
<hash
> <mode
></code></pre>
2396 <div class=
"paragraph"><p>File modes are printed as
6-digit octal numbers including the file type
2397 and file permission bits.
</p></div>
2398 <div class=
"paragraph"><p>Path names in extended headers do not include the
<code>a/
</code> and
<code>b/
</code> prefixes.
</p></div>
2399 <div class=
"paragraph"><p>The similarity index is the percentage of unchanged lines, and
2400 the dissimilarity index is the percentage of changed lines. It
2401 is a rounded down integer, followed by a percent sign. The
2402 similarity index value of
100% is thus reserved for two equal
2403 files, while
100% dissimilarity means that no line from the old
2404 file made it into the new one.
</p></div>
2405 <div class=
"paragraph"><p>The index line includes the blob object names before and after the change.
2406 The
<mode
> is included if the file mode does not change; otherwise,
2407 separate lines indicate the old and the new mode.
</p></div>
2411 Pathnames with
"unusual" characters are quoted as explained for
2412 the configuration variable
<code>core.quotePath
</code> (see
2413 <a href=
"git-config.html">git-config(
1)
</a>).
2418 All the
<code>file1
</code> files in the output refer to files before the
2419 commit, and all the
<code>file2
</code> files refer to files after the commit.
2420 It is incorrect to apply each change to each file sequentially. For
2421 example, this patch will swap a and b:
2423 <div class=
"literalblock">
2424 <div class=
"content">
2425 <pre><code>diff --git a/a b/b
2430 rename to a
</code></pre>
2435 Hunk headers mention the name of the function to which the hunk
2436 applies. See
"Defining a custom hunk-header" in
2437 <a href=
"gitattributes.html">gitattributes(
5)
</a> for details of how to tailor this to
2445 <h2 id=
"_combined_diff_format">Combined diff format
</h2>
2446 <div class=
"sectionbody">
2447 <div class=
"paragraph"><p>Any diff-generating command can take the
<code>-c
</code> or
<code>--cc
</code> option to
2448 produce a
<em>combined diff
</em> when showing a merge. This is the default
2449 format when showing merges with
<a href=
"git-diff.html">git-diff(
1)
</a> or
2450 <a href=
"git-show.html">git-show(
1)
</a>. Note also that you can give suitable
2451 <code>--diff-merges
</code> option to any of these commands to force generation of
2452 diffs in a specific format.
</p></div>
2453 <div class=
"paragraph"><p>A
"combined diff" format looks like this:
</p></div>
2454 <div class=
"listingblock">
2455 <div class=
"content">
2456 <pre><code>diff --combined describe.c
2457 index fabadb8,cc95eb0.
.4866510
2460 @@@ -
98,
20 -
98,
12 +
98,
20 @@@
2461 return (a_date
> b_date) ? -
1 : (a_date == b_date) ?
0 :
1;
2464 - static void describe(char *arg)
2465 -static void describe(struct commit *cmit, int last_one)
2466 ++static void describe(char *arg, int last_one)
2468 + unsigned char sha1[
20];
2469 + struct commit *cmit;
2470 struct commit_list *list;
2471 static int initialized =
0;
2472 struct commit_name *n;
2474 + if (get_sha1(arg, sha1)
< 0)
2475 + usage(describe_usage);
2476 + cmit = lookup_commit_reference(sha1);
2478 + usage(describe_usage);
2482 for_each_ref(get_name);
</code></pre>
2484 <div class=
"olist arabic"><ol class=
"arabic">
2487 It is preceded by a
"git diff" header, that looks like
2488 this (when the
<code>-c
</code> option is used):
2490 <div class=
"literalblock">
2491 <div class=
"content">
2492 <pre><code>diff --combined file
</code></pre>
2494 <div class=
"paragraph"><p>or like this (when the
<code>--cc
</code> option is used):
</p></div>
2495 <div class=
"literalblock">
2496 <div class=
"content">
2497 <pre><code>diff --cc file
</code></pre>
2502 It is followed by one or more extended header lines
2503 (this example shows a merge with two parents):
2505 <div class=
"literalblock">
2506 <div class=
"content">
2507 <pre><code>index
<hash
>,
<hash
>..
<hash
>
2508 mode
<mode
>,
<mode
>..
<mode
>
2509 new file mode
<mode
>
2510 deleted file mode
<mode
>,
<mode
></code></pre>
2512 <div class=
"paragraph"><p>The
<code>mode
<mode
>,
<mode
>..
<mode
></code> line appears only if at least one of
2513 the
<mode
> is different from the rest. Extended headers with
2514 information about detected content movement (renames and
2515 copying detection) are designed to work with the diff of two
2516 <tree-ish
> and are not used by combined diff format.
</p></div>
2520 It is followed by a two-line from-file/to-file header:
2522 <div class=
"literalblock">
2523 <div class=
"content">
2524 <pre><code>--- a/file
2525 +++ b/file
</code></pre>
2527 <div class=
"paragraph"><p>Similar to the two-line header for the traditional
<em>unified
</em> diff
2528 format,
<code>/dev/null
</code> is used to signal created or deleted
2530 <div class=
"paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
2531 two-line from-file/to-file, you get an N+
1 line from-file/to-file header,
2532 where N is the number of parents in the merge commit:
</p></div>
2533 <div class=
"literalblock">
2534 <div class=
"content">
2535 <pre><code>--- a/file
2538 +++ b/file
</code></pre>
2540 <div class=
"paragraph"><p>This extended format can be useful if rename or copy detection is
2541 active, to allow you to see the original name of the file in different
2546 Chunk header format is modified to prevent people from
2547 accidentally feeding it to
<code>patch -p1
</code>. Combined diff format
2548 was created for review of merge commit changes, and was not
2549 meant to be applied. The change is similar to the change in the
2550 extended
<em>index
</em> header:
2552 <div class=
"literalblock">
2553 <div class=
"content">
2554 <pre><code>@@@
<from-file-range
> <from-file-range
> <to-file-range
> @@@
</code></pre>
2556 <div class=
"paragraph"><p>There are (number of parents +
1)
<code>@
</code> characters in the chunk
2557 header for combined diff format.
</p></div>
2560 <div class=
"paragraph"><p>Unlike the traditional
<em>unified
</em> diff format, which shows two
2561 files A and B with a single column that has
<code>-
</code> (minus
 — appears in A but removed in B),
<code>+
</code> (plus
 — missing in A but
2562 added to B), or
<code>" "</code> (space
 — unchanged) prefix, this format
2563 compares two or more files file1, file2,
… with one file X, and
2564 shows how X differs from each of fileN. One column for each of
2565 fileN is prepended to the output line to note how X
’s line is
2566 different from it.
</p></div>
2567 <div class=
"paragraph"><p>A
<code>-
</code> character in the column N means that the line appears in
2568 fileN but it does not appear in the result. A
<code>+
</code> character
2569 in the column N means that the line appears in the result,
2570 and fileN does not have that line (in other words, the line was
2571 added, from the point of view of that parent).
</p></div>
2572 <div class=
"paragraph"><p>In the above example output, the function signature was changed
2573 from both files (hence two
<code>-
</code> removals from both file1 and
2574 file2, plus
<code>++
</code> to mean one line that was added does not appear
2575 in either file1 or file2). Also, eight other lines are the same
2576 from file1 but do not appear in file2 (hence prefixed with
<code>+
</code>).
</p></div>
2577 <div class=
"paragraph"><p>When shown by
<code>git diff-tree -c
</code>, it compares the parents of a
2578 merge commit with the merge result (i.e. file1..fileN are the
2579 parents). When shown by
<code>git diff-files -c
</code>, it compares the
2580 two unresolved merge parents with the working tree file
2581 (i.e. file1 is stage
2 aka
"our version", file2 is stage
3 aka
2582 "their version").
</p></div>
2586 <h2 id=
"_other_diff_formats">other diff formats
</h2>
2587 <div class=
"sectionbody">
2588 <div class=
"paragraph"><p>The
<code>--summary
</code> option describes newly added, deleted, renamed and
2589 copied files. The
<code>--stat
</code> option adds diffstat(
1) graph to the
2590 output. These options can be combined with other options, such as
2591 <code>-p
</code>, and are meant for human consumption.
</p></div>
2592 <div class=
"paragraph"><p>When showing a change that involves a rename or a copy,
<code>--stat
</code> output
2593 formats the pathnames compactly by combining common prefix and suffix of
2594 the pathnames. For example, a change that moves
<code>arch/i386/Makefile
</code> to
2595 <code>arch/x86/Makefile
</code> while modifying
4 lines will be shown like this:
</p></div>
2596 <div class=
"listingblock">
2597 <div class=
"content">
2598 <pre><code>arch/{i386 =
> x86}/Makefile |
4 +--
</code></pre>
2600 <div class=
"paragraph"><p>The
<code>--numstat
</code> option gives the diffstat(
1) information but is designed
2601 for easier machine consumption. An entry in
<code>--numstat
</code> output looks
2602 like this:
</p></div>
2603 <div class=
"listingblock">
2604 <div class=
"content">
2605 <pre><code>1 2 README
2606 3 1 arch/{i386 =
> x86}/Makefile
</code></pre>
2608 <div class=
"paragraph"><p>That is, from left to right:
</p></div>
2609 <div class=
"olist arabic"><ol class=
"arabic">
2612 the number of added lines;
2622 the number of deleted lines;
2632 pathname (possibly with rename/copy information);
2641 <div class=
"paragraph"><p>When
<code>-z
</code> output option is in effect, the output is formatted this way:
</p></div>
2642 <div class=
"listingblock">
2643 <div class=
"content">
2644 <pre><code>1 2 README NUL
2645 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
</code></pre>
2647 <div class=
"paragraph"><p>That is:
</p></div>
2648 <div class=
"olist arabic"><ol class=
"arabic">
2651 the number of added lines;
2661 the number of deleted lines;
2671 a NUL (only exists if renamed/copied);
2676 pathname in preimage;
2681 a NUL (only exists if renamed/copied);
2686 pathname in postimage (only exists if renamed/copied);
2695 <div class=
"paragraph"><p>The extra
<code>NUL
</code> before the preimage path in renamed case is to allow
2696 scripts that read the output to tell if the current record being read is
2697 a single-path record or a rename/copy record without reading ahead.
2698 After reading added and deleted lines, reading up to
<code>NUL
</code> would yield
2699 the pathname, but if that is
<code>NUL
</code>, the record will show two paths.
</p></div>
2703 <h2 id=
"_operating_modes">OPERATING MODES
</h2>
2704 <div class=
"sectionbody">
2705 <div class=
"paragraph"><p>You can choose whether you want to trust the index file entirely
2706 (using the
<code>--cached
</code> flag) or ask the diff logic to show any files
2707 that don
’t match the stat state as being
"tentatively changed". Both
2708 of these operations are very useful indeed.
</p></div>
2712 <h2 id=
"_cached_mode">CACHED MODE
</h2>
2713 <div class=
"sectionbody">
2714 <div class=
"paragraph"><p>If
<code>--cached
</code> is specified, it allows you to ask:
</p></div>
2715 <div class=
"literalblock">
2716 <div class=
"content">
2717 <pre><code>show me the differences between HEAD and the current index
2718 contents (the ones I'd write using 'git write-tree')
</code></pre>
2720 <div class=
"paragraph"><p>For example, let
’s say that you have worked on your working directory, updated
2721 some files in the index and are ready to commit. You want to see exactly
2722 <strong>what
</strong> you are going to commit, without having to write a new tree
2723 object and compare it that way, and to do that, you just do
</p></div>
2724 <div class=
"literalblock">
2725 <div class=
"content">
2726 <pre><code>git diff-index --cached HEAD
</code></pre>
2728 <div class=
"paragraph"><p>Example: let
’s say I had renamed
<code>commit.c
</code> to
<code>git-commit.c
</code>, and I had
2729 done an
<code>update-index
</code> to make that effective in the index file.
2730 <code>git diff-files
</code> wouldn
’t show anything at all, since the index file
2731 matches my working directory. But doing a
<em>git diff-index
</em> does:
</p></div>
2732 <div class=
"literalblock">
2733 <div class=
"content">
2734 <pre><code>torvalds@ppc970:~/git
> git diff-index --cached HEAD
2735 :
100644 000000 4161aecc6700a2eb579e842af0b7f22b98443f74
0000000000000000000000000000000000000000 D commit.c
2736 :
000000 100644 0000000000000000000000000000000000000000 4161aecc6700a2eb579e842af0b7f22b98443f74 A git-commit.c
</code></pre>
2738 <div class=
"paragraph"><p>You can see easily that the above is a rename.
</p></div>
2739 <div class=
"paragraph"><p>In fact,
<code>git diff-index --cached
</code> <strong>should
</strong> always be entirely equivalent to
2740 actually doing a
<em>git write-tree
</em> and comparing that. Except this one is much
2741 nicer for the case where you just want to check where you are.
</p></div>
2742 <div class=
"paragraph"><p>So doing a
<code>git diff-index --cached
</code> is basically very useful when you are
2743 asking yourself
"what have I already marked for being committed, and
2744 what’s the difference to a previous tree".
</p></div>
2748 <h2 id=
"_non_cached_mode">NON-CACHED MODE
</h2>
2749 <div class=
"sectionbody">
2750 <div class=
"paragraph"><p>The
"non-cached" mode takes a different approach, and is potentially
2751 the more useful of the two in that what it does can
’t be emulated with
2752 a
<em>git write-tree
</em> +
<em>git diff-tree
</em>. Thus that
’s the default mode.
2753 The non-cached version asks the question:
</p></div>
2754 <div class=
"literalblock">
2755 <div class=
"content">
2756 <pre><code>show me the differences between HEAD and the currently checked out
2757 tree - index contents _and_ files that aren't up to date
</code></pre>
2759 <div class=
"paragraph"><p>which is obviously a very useful question too, since that tells you what
2760 you
<strong>could
</strong> commit. Again, the output matches the
<em>git diff-tree -r
</em>
2761 output to a tee, but with a twist.
</p></div>
2762 <div class=
"paragraph"><p>The twist is that if some file doesn
’t match the index, we don
’t have
2763 a backing store thing for it, and we use the magic
"all-zero" sha1 to
2764 show that. So let
’s say that you have edited
<code>kernel/sched.c
</code>, but
2765 have not actually done a
<em>git update-index
</em> on it yet - there is no
2766 "object" associated with the new state, and you get:
</p></div>
2767 <div class=
"literalblock">
2768 <div class=
"content">
2769 <pre><code>torvalds@ppc970:~/v2.6/linux
> git diff-index --abbrev HEAD
2770 :
100644 100644 7476bb5ba
000000000 M kernel/sched.c
</code></pre>
2772 <div class=
"paragraph"><p>i.e., it shows that the tree has changed, and that
<code>kernel/sched.c
</code> is
2773 not up to date and may contain new stuff. The all-zero sha1 means that to
2774 get the real diff, you need to look at the object in the working directory
2775 directly rather than do an object-to-object diff.
</p></div>
2776 <div class=
"admonitionblock">
2779 <div class=
"title">Note
</div>
2781 <td class=
"content">As with other commands of this type,
<em>git diff-index
</em> does not
2782 actually look at the contents of the file at all. So maybe
2783 <code>kernel/sched.c
</code> hasn
’t actually changed, and it
’s just that you
2784 touched it. In either case, it
’s a note that you need to
2785 <em>git update-index
</em> it to make the index be in sync.
</td>
2788 <div class=
"admonitionblock">
2791 <div class=
"title">Note
</div>
2793 <td class=
"content">You can have a mixture of files show up as
"has been updated"
2794 and
"is still dirty in the working directory" together. You can always
2795 tell which file is in which state, since the
"has been updated" ones
2796 show a valid sha1, and the
"not in sync with the index" ones will
2797 always have the special all-zero sha1.
</td>
2803 <h2 id=
"_git">GIT
</h2>
2804 <div class=
"sectionbody">
2805 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
2809 <div id=
"footnotes"><hr /></div>
2811 <div id=
"footer-text">
2813 2023-
10-
23 14:
43:
46 PDT