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(
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(
1) Manual Page
741 <div class=
"sectionbody">
743 Show changes between commits, commit and working tree, etc
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><em>git diff
</em> [
<options
>] [
<commit
>] [--] [
<path
>…]
753 <em>git diff
</em> [
<options
>] --cached [--merge-base] [
<commit
>] [--] [
<path
>…]
754 <em>git diff
</em> [
<options
>] [--merge-base]
<commit
> [
<commit
>…]
<commit
> [--] [
<path
>…]
755 <em>git diff
</em> [
<options
>]
<commit
>…<commit
> [--] [
<path
>…]
756 <em>git diff
</em> [
<options
>]
<blob
> <blob
>
757 <em>git diff
</em> [
<options
>] --no-index [--]
<path
> <path
></pre>
758 <div class=
"attribution">
763 <h2 id=
"_description">DESCRIPTION
</h2>
764 <div class=
"sectionbody">
765 <div class=
"paragraph"><p>Show changes between the working tree and the index or a tree, changes
766 between the index and a tree, changes between two trees, changes resulting
767 from a merge, changes between two blob objects, or changes between two
768 files on disk.
</p></div>
769 <div class=
"dlist"><dl>
771 <em>git diff
</em> [
<options
>] [--] [
<path
>…]
775 This form is to view the changes you made relative to
776 the index (staging area for the next commit). In other
777 words, the differences are what you
<em>could
</em> tell Git to
778 further add to the index but you still haven
’t. You can
779 stage these changes by using
<a href=
"git-add.html">git-add(
1)
</a>.
783 <em>git diff
</em> [
<options
>] --no-index [--]
<path
> <path
>
787 This form is to compare the given two paths on the
788 filesystem. You can omit the
<code>--no-index
</code> option when
789 running the command in a working tree controlled by Git and
790 at least one of the paths points outside the working tree,
791 or when running the command outside a working tree
792 controlled by Git. This form implies
<code>--exit-code
</code>.
796 <em>git diff
</em> [
<options
>] --cached [--merge-base] [
<commit
>] [--] [
<path
>…]
800 This form is to view the changes you staged for the next
801 commit relative to the named
<commit
>. Typically you
802 would want comparison with the latest commit, so if you
803 do not give
<commit
>, it defaults to HEAD.
804 If HEAD does not exist (e.g. unborn branches) and
805 <commit
> is not given, it shows all staged changes.
806 --staged is a synonym of --cached.
808 <div class=
"paragraph"><p>If --merge-base is given, instead of using
<commit
>, use the merge base
809 of
<commit
> and HEAD.
<code>git diff --cached --merge-base A
</code> is equivalent to
810 <code>git diff --cached $(git merge-base A HEAD)
</code>.
</p></div>
813 <em>git diff
</em> [
<options
>] [--merge-base]
<commit
> [--] [
<path
>…]
817 This form is to view the changes you have in your
818 working tree relative to the named
<commit
>. You can
819 use HEAD to compare it with the latest commit, or a
820 branch name to compare with the tip of a different
823 <div class=
"paragraph"><p>If --merge-base is given, instead of using
<commit
>, use the merge base
824 of
<commit
> and HEAD.
<code>git diff --merge-base A
</code> is equivalent to
825 <code>git diff $(git merge-base A HEAD)
</code>.
</p></div>
828 <em>git diff
</em> [
<options
>] [--merge-base]
<commit
> <commit
> [--] [
<path
>…]
832 This is to view the changes between two arbitrary
835 <div class=
"paragraph"><p>If --merge-base is given, use the merge base of the two commits for the
836 "before" side.
<code>git diff --merge-base A B
</code> is equivalent to
837 <code>git diff $(git merge-base A B) B
</code>.
</p></div>
840 <em>git diff
</em> [
<options
>]
<commit
> <commit
>… <commit
> [--] [
<path
>…]
844 This form is to view the results of a merge commit. The first
845 listed
<commit
> must be the merge itself; the remaining two or
846 more commits should be its parents. Convenient ways to produce
847 the desired set of revisions are to use the suffixes
<code>^@
</code> and
848 <code>^!
</code>. If A is a merge commit, then
<code>git diff A A^@
</code>,
849 <code>git diff A^!
</code> and
<code>git show A
</code> all give the same combined diff.
853 <em>git diff
</em> [
<options
>]
<commit
>..
<commit
> [--] [
<path
>…]
857 This is synonymous to the earlier form (without the
<code>..
</code>) for
858 viewing the changes between two arbitrary
<commit
>. If
<commit
> on
859 one side is omitted, it will have the same effect as
864 <em>git diff
</em> [
<options
>]
<commit
>...
<commit
> [--] [
<path
>…]
868 This form is to view the changes on the branch containing
869 and up to the second
<commit
>, starting at a common ancestor
870 of both
<commit
>.
<code>git diff A...B
</code> is equivalent to
871 <code>git diff $(git merge-base A B) B
</code>. You can omit any one
872 of
<commit
>, which has the same effect as using HEAD instead.
876 <div class=
"paragraph"><p>Just in case you are doing something exotic, it should be
877 noted that all of the
<commit
> in the above description, except
878 in the
<code>--merge-base
</code> case and in the last two forms that use
<code>..
</code>
879 notations, can be any
<tree
>. A tree of interest is the one pointed to
880 by the ref named
<code>AUTO_MERGE
</code>, which is written by the
<em>ort
</em> merge
881 strategy upon hitting merge conflicts (see
<a href=
"git-merge.html">git-merge(
1)
</a>).
882 Comparing the working tree with
<code>AUTO_MERGE
</code> shows changes you
’ve made
883 so far to resolve textual conflicts (see the examples below).
</p></div>
884 <div class=
"paragraph"><p>For a more complete list of ways to spell
<commit
>, see
885 "SPECIFYING REVISIONS" section in
<a href=
"gitrevisions.html">gitrevisions(
7)
</a>.
886 However,
"diff" is about comparing two
<em>endpoints
</em>, not ranges,
887 and the range notations (
<code><commit
>..
<commit
></code> and
888 <code><commit
>...
<commit
></code>) do not mean a range as defined in the
889 "SPECIFYING RANGES" section in
<a href=
"gitrevisions.html">gitrevisions(
7)
</a>.
</p></div>
890 <div class=
"dlist"><dl>
892 <em>git diff
</em> [
<options
>]
<blob
> <blob
>
896 This form is to view the differences between the raw
897 contents of two blob objects.
904 <h2 id=
"_options">OPTIONS
</h2>
905 <div class=
"sectionbody">
906 <div class=
"dlist"><dl>
918 Generate patch (see
<a href=
"#generate_patch_text_with_p">[generate_patch_text_with_p]
</a>).
930 Suppress all output from the diff machinery. Useful for
931 commands like
<code>git show
</code> that show the patch by default to
932 squelch their output, or to cancel the effect of options like
933 <code>--patch
</code>,
<code>--stat
</code> earlier on the command line in an alias.
944 Generate diffs with
<n
> lines of context instead of
946 Implies
<code>--patch
</code>.
950 --output=
<file
>
954 Output to a specific file instead of stdout.
958 --output-indicator-new=
<char
>
961 --output-indicator-old=
<char
>
964 --output-indicator-context=
<char
>
968 Specify the character used to indicate new, old or context
969 lines in the generated patch. Normally they are
<em>+
</em>,
<em>-
</em> and
978 Generate the diff in raw format.
986 Synonym for
<code>-p --raw
</code>.
994 Enable the heuristic that shifts diff hunk boundaries to make patches
995 easier to read. This is the default.
999 --no-indent-heuristic
1003 Disable the indent heuristic.
1006 <dt class=
"hdlist1">
1011 Spend extra time to make sure the smallest possible
1015 <dt class=
"hdlist1">
1020 Generate a diff using the
"patience diff" algorithm.
1023 <dt class=
"hdlist1">
1028 Generate a diff using the
"histogram diff" algorithm.
1031 <dt class=
"hdlist1">
1032 --anchored=
<text
>
1036 Generate a diff using the
"anchored diff" algorithm.
1038 <div class=
"paragraph"><p>This option may be specified more than once.
</p></div>
1039 <div class=
"paragraph"><p>If a line exists in both the source and destination, exists only once,
1040 and starts with this text, this algorithm attempts to prevent it from
1041 appearing as a deletion or addition in the output. It uses the
"patience
1042 diff" algorithm internally.
</p></div>
1044 <dt class=
"hdlist1">
1045 --diff-algorithm={patience|minimal|histogram|myers}
1049 Choose a diff algorithm. The variants are as follows:
1051 <div class=
"openblock">
1052 <div class=
"content">
1053 <div class=
"dlist"><dl>
1054 <dt class=
"hdlist1">
1055 <code>default
</code>,
<code>myers
</code>
1059 The basic greedy diff algorithm. Currently, this is the default.
1062 <dt class=
"hdlist1">
1063 <code>minimal
</code>
1067 Spend extra time to make sure the smallest possible diff is
1071 <dt class=
"hdlist1">
1072 <code>patience
</code>
1076 Use
"patience diff" algorithm when generating patches.
1079 <dt class=
"hdlist1">
1080 <code>histogram
</code>
1084 This algorithm extends the patience algorithm to
"support
1085 low-occurrence common elements".
1090 <div class=
"paragraph"><p>For instance, if you configured the
<code>diff.algorithm
</code> variable to a
1091 non-default value and want to use the default one, then you
1092 have to use
<code>--diff-algorithm=default
</code> option.
</p></div>
1094 <dt class=
"hdlist1">
1095 --stat[=
<width
>[,
<name-width
>[,
<count
>]]]
1099 Generate a diffstat. By default, as much space as necessary
1100 will be used for the filename part, and the rest for the graph
1101 part. Maximum width defaults to terminal width, or
80 columns
1102 if not connected to a terminal, and can be overridden by
1103 <code><width
></code>. The width of the filename part can be limited by
1104 giving another width
<code><name-width
></code> after a comma or by setting
1105 <code>diff.statNameWidth=
<width
></code>. The width of the graph part can be
1106 limited by using
<code>--stat-graph-width=
<width
></code> or by setting
1107 <code>diff.statGraphWidth=
<width
></code>. Using
<code>--stat
</code> or
1108 <code>--stat-graph-width
</code> affects all commands generating a stat graph,
1109 while setting
<code>diff.statNameWidth
</code> or
<code>diff.statGraphWidth
</code>
1110 does not affect
<code>git format-patch
</code>.
1111 By giving a third parameter
<code><count
></code>, you can limit the output to
1112 the first
<code><count
></code> lines, followed by
<code>...
</code> if there are more.
1114 <div class=
"paragraph"><p>These parameters can also be set individually with
<code>--stat-width=
<width
></code>,
1115 <code>--stat-name-width=
<name-width
></code> and
<code>--stat-count=
<count
></code>.
</p></div>
1117 <dt class=
"hdlist1">
1122 Output a condensed summary of extended header information such
1123 as file creations or deletions (
"new" or
"gone", optionally
"+l"
1124 if it
’s a symlink) and mode changes (
"+x" or
"-x" for adding
1125 or removing executable bit respectively) in diffstat. The
1126 information is put between the filename part and the graph
1127 part. Implies
<code>--stat
</code>.
1130 <dt class=
"hdlist1">
1135 Similar to
<code>--stat
</code>, but shows number of added and
1136 deleted lines in decimal notation and pathname without
1137 abbreviation, to make it more machine friendly. For
1138 binary files, outputs two
<code>-
</code> instead of saying
1142 <dt class=
"hdlist1">
1147 Output only the last line of the
<code>--stat
</code> format containing total
1148 number of modified files, as well as number of added and deleted
1152 <dt class=
"hdlist1">
1153 -X[
<param1,param2,
…>]
1155 <dt class=
"hdlist1">
1156 --dirstat[=
<param1,param2,
…>]
1160 Output the distribution of relative amount of changes for each
1161 sub-directory. The behavior of
<code>--dirstat
</code> can be customized by
1162 passing it a comma separated list of parameters.
1163 The defaults are controlled by the
<code>diff.dirstat
</code> configuration
1164 variable (see
<a href=
"git-config.html">git-config(
1)
</a>).
1165 The following parameters are available:
1167 <div class=
"openblock">
1168 <div class=
"content">
1169 <div class=
"dlist"><dl>
1170 <dt class=
"hdlist1">
1171 <code>changes
</code>
1175 Compute the dirstat numbers by counting the lines that have been
1176 removed from the source, or added to the destination. This ignores
1177 the amount of pure code movements within a file. In other words,
1178 rearranging lines in a file is not counted as much as other changes.
1179 This is the default behavior when no parameter is given.
1182 <dt class=
"hdlist1">
1187 Compute the dirstat numbers by doing the regular line-based diff
1188 analysis, and summing the removed/added line counts. (For binary
1189 files, count
64-byte chunks instead, since binary files have no
1190 natural concept of lines). This is a more expensive
<code>--dirstat
</code>
1191 behavior than the
<code>changes
</code> behavior, but it does count rearranged
1192 lines within a file as much as other changes. The resulting output
1193 is consistent with what you get from the other
<code>--*stat
</code> options.
1196 <dt class=
"hdlist1">
1201 Compute the dirstat numbers by counting the number of files changed.
1202 Each changed file counts equally in the dirstat analysis. This is
1203 the computationally cheapest
<code>--dirstat
</code> behavior, since it does
1204 not have to look at the file contents at all.
1207 <dt class=
"hdlist1">
1208 <code>cumulative
</code>
1212 Count changes in a child directory for the parent directory as well.
1213 Note that when using
<code>cumulative
</code>, the sum of the percentages
1214 reported may exceed
100%. The default (non-cumulative) behavior can
1215 be specified with the
<code>noncumulative
</code> parameter.
1218 <dt class=
"hdlist1">
1223 An integer parameter specifies a cut-off percent (
3% by default).
1224 Directories contributing less than this percentage of the changes
1225 are not shown in the output.
1230 <div class=
"paragraph"><p>Example: The following will count changed files, while ignoring
1231 directories with less than
10% of the total amount of changed files,
1232 and accumulating child directory counts in the parent directories:
1233 <code>--dirstat=files,
10,cumulative
</code>.
</p></div>
1235 <dt class=
"hdlist1">
1240 Synonym for --dirstat=cumulative
1243 <dt class=
"hdlist1">
1244 --dirstat-by-file[=
<param1,param2
>…]
1248 Synonym for --dirstat=files,param1,param2
…
1251 <dt class=
"hdlist1">
1256 Output a condensed summary of extended header information
1257 such as creations, renames and mode changes.
1260 <dt class=
"hdlist1">
1265 Synonym for
<code>-p --stat
</code>.
1268 <dt class=
"hdlist1">
1273 When
<code>--raw
</code>,
<code>--numstat
</code>,
<code>--name-only
</code> or
<code>--name-status
</code> has been
1274 given, do not munge pathnames and use NULs as output field terminators.
1276 <div class=
"paragraph"><p>Without this option, pathnames with
"unusual" characters are quoted as
1277 explained for the configuration variable
<code>core.quotePath
</code> (see
1278 <a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
1280 <dt class=
"hdlist1">
1285 Show only names of changed files. The file names are often encoded in UTF-
8.
1286 For more information see the discussion about encoding in the
<a href=
"git-log.html">git-log(
1)
</a>
1290 <dt class=
"hdlist1">
1295 Show only names and status of changed files. See the description
1296 of the
<code>--diff-filter
</code> option on what the status letters mean.
1297 Just like
<code>--name-only
</code> the file names are often encoded in UTF-
8.
1300 <dt class=
"hdlist1">
1301 --submodule[=
<format
>]
1305 Specify how differences in submodules are shown. When specifying
1306 <code>--submodule=short
</code> the
<em>short
</em> format is used. This format just
1307 shows the names of the commits at the beginning and end of the range.
1308 When
<code>--submodule
</code> or
<code>--submodule=log
</code> is specified, the
<em>log
</em>
1309 format is used. This format lists the commits in the range like
1310 <a href=
"git-submodule.html">git-submodule(
1)
</a> <code>summary
</code> does. When
<code>--submodule=diff
</code>
1311 is specified, the
<em>diff
</em> format is used. This format shows an
1312 inline diff of the changes in the submodule contents between the
1313 commit range. Defaults to
<code>diff.submodule
</code> or the
<em>short
</em> format
1314 if the config option is unset.
1317 <dt class=
"hdlist1">
1318 --color[=
<when
>]
1323 <code>--color
</code> (i.e. without
<em>=
<when
></em>) is the same as
<code>--color=always
</code>.
1324 <em><when
></em> can be one of
<code>always
</code>,
<code>never
</code>, or
<code>auto
</code>.
1325 It can be changed by the
<code>color.ui
</code> and
<code>color.diff
</code>
1326 configuration settings.
1329 <dt class=
"hdlist1">
1334 Turn off colored diff.
1335 This can be used to override configuration settings.
1336 It is the same as
<code>--color=never
</code>.
1339 <dt class=
"hdlist1">
1340 --color-moved[=
<mode
>]
1344 Moved lines of code are colored differently.
1345 It can be changed by the
<code>diff.colorMoved
</code> configuration setting.
1346 The
<mode
> defaults to
<em>no
</em> if the option is not given
1347 and to
<em>zebra
</em> if the option with no mode is given.
1348 The mode must be one of:
1350 <div class=
"openblock">
1351 <div class=
"content">
1352 <div class=
"dlist"><dl>
1353 <dt class=
"hdlist1">
1358 Moved lines are not highlighted.
1361 <dt class=
"hdlist1">
1366 Is a synonym for
<code>zebra
</code>. This may change to a more sensible mode
1370 <dt class=
"hdlist1">
1375 Any line that is added in one location and was removed
1376 in another location will be colored with
<em>color.diff.newMoved
</em>.
1377 Similarly
<em>color.diff.oldMoved
</em> will be used for removed lines
1378 that are added somewhere else in the diff. This mode picks up any
1379 moved line, but it is not very useful in a review to determine
1380 if a block of code was moved without permutation.
1383 <dt class=
"hdlist1">
1388 Blocks of moved text of at least
20 alphanumeric characters
1389 are detected greedily. The detected blocks are
1390 painted using either the
<em>color.diff.{old,new}Moved
</em> color.
1391 Adjacent blocks cannot be told apart.
1394 <dt class=
"hdlist1">
1399 Blocks of moved text are detected as in
<em>blocks
</em> mode. The blocks
1400 are painted using either the
<em>color.diff.{old,new}Moved
</em> color or
1401 <em>color.diff.{old,new}MovedAlternative
</em>. The change between
1402 the two colors indicates that a new block was detected.
1405 <dt class=
"hdlist1">
1410 Similar to
<em>zebra
</em>, but additional dimming of uninteresting parts
1411 of moved code is performed. The bordering lines of two adjacent
1412 blocks are considered interesting, the rest is uninteresting.
1413 <code>dimmed_zebra
</code> is a deprecated synonym.
1419 <dt class=
"hdlist1">
1424 Turn off move detection. This can be used to override configuration
1425 settings. It is the same as
<code>--color-moved=no
</code>.
1428 <dt class=
"hdlist1">
1429 --color-moved-ws=
<modes
>
1433 This configures how whitespace is ignored when performing the
1434 move detection for
<code>--color-moved
</code>.
1435 It can be set by the
<code>diff.colorMovedWS
</code> configuration setting.
1436 These modes can be given as a comma separated list:
1438 <div class=
"openblock">
1439 <div class=
"content">
1440 <div class=
"dlist"><dl>
1441 <dt class=
"hdlist1">
1446 Do not ignore whitespace when performing move detection.
1449 <dt class=
"hdlist1">
1454 Ignore changes in whitespace at EOL.
1457 <dt class=
"hdlist1">
1462 Ignore changes in amount of whitespace. This ignores whitespace
1463 at line end, and considers all other sequences of one or
1464 more whitespace characters to be equivalent.
1467 <dt class=
"hdlist1">
1472 Ignore whitespace when comparing lines. This ignores differences
1473 even if one line has whitespace where the other line has none.
1476 <dt class=
"hdlist1">
1477 allow-indentation-change
1481 Initially ignore any whitespace in the move detection, then
1482 group the moved code blocks only into a block if the change in
1483 whitespace is the same per line. This is incompatible with the
1490 <dt class=
"hdlist1">
1495 Do not ignore whitespace when performing move detection. This can be
1496 used to override configuration settings. It is the same as
1497 <code>--color-moved-ws=no
</code>.
1500 <dt class=
"hdlist1">
1501 --word-diff[=
<mode
>]
1505 Show a word diff, using the
<mode
> to delimit changed words.
1506 By default, words are delimited by whitespace; see
1507 <code>--word-diff-regex
</code> below. The
<mode
> defaults to
<em>plain
</em>, and
1510 <div class=
"openblock">
1511 <div class=
"content">
1512 <div class=
"dlist"><dl>
1513 <dt class=
"hdlist1">
1518 Highlight changed words using only colors. Implies
<code>--color
</code>.
1521 <dt class=
"hdlist1">
1526 Show words as
<code>[-removed-]
</code> and
<code>{+added+}
</code>. Makes no
1527 attempts to escape the delimiters if they appear in the input,
1528 so the output may be ambiguous.
1531 <dt class=
"hdlist1">
1536 Use a special line-based format intended for script
1537 consumption. Added/removed/unchanged runs are printed in the
1538 usual unified diff format, starting with a
<code>+
</code>/
<code>-
</code>/` `
1539 character at the beginning of the line and extending to the
1540 end of the line. Newlines in the input are represented by a
1541 tilde
<code>~
</code> on a line of its own.
1544 <dt class=
"hdlist1">
1549 Disable word diff again.
1554 <div class=
"paragraph"><p>Note that despite the name of the first mode, color is used to
1555 highlight the changed parts in all modes if enabled.
</p></div>
1557 <dt class=
"hdlist1">
1558 --word-diff-regex=
<regex
>
1562 Use
<regex
> to decide what a word is, instead of considering
1563 runs of non-whitespace to be a word. Also implies
1564 <code>--word-diff
</code> unless it was already enabled.
1566 <div class=
"paragraph"><p>Every non-overlapping match of the
1567 <regex
> is considered a word. Anything between these matches is
1568 considered whitespace and ignored(!) for the purposes of finding
1569 differences. You may want to append
<code>|[^[:space:]]
</code> to your regular
1570 expression to make sure that it matches all non-whitespace characters.
1571 A match that contains a newline is silently truncated(!) at the
1573 <div class=
"paragraph"><p>For example,
<code>--word-diff-regex=.
</code> will treat each character as a word
1574 and, correspondingly, show differences character by character.
</p></div>
1575 <div class=
"paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1576 <a href=
"gitattributes.html">gitattributes(
5)
</a> or
<a href=
"git-config.html">git-config(
1)
</a>. Giving it explicitly
1577 overrides any diff driver or configuration setting. Diff drivers
1578 override configuration settings.
</p></div>
1580 <dt class=
"hdlist1">
1581 --color-words[=
<regex
>]
1585 Equivalent to
<code>--word-diff=color
</code> plus (if a regex was
1586 specified)
<code>--word-diff-regex=
<regex
></code>.
1589 <dt class=
"hdlist1">
1594 Turn off rename detection, even when the configuration
1595 file gives the default to do so.
1598 <dt class=
"hdlist1">
1603 Whether to use empty blobs as rename source.
1606 <dt class=
"hdlist1">
1611 Warn if changes introduce conflict markers or whitespace errors.
1612 What are considered whitespace errors is controlled by
<code>core.whitespace
</code>
1613 configuration. By default, trailing whitespaces (including
1614 lines that consist solely of whitespaces) and a space character
1615 that is immediately followed by a tab character inside the
1616 initial indent of the line are considered whitespace errors.
1617 Exits with non-zero status if problems are found. Not compatible
1621 <dt class=
"hdlist1">
1622 --ws-error-highlight=
<kind
>
1626 Highlight whitespace errors in the
<code>context
</code>,
<code>old
</code> or
<code>new
</code>
1627 lines of the diff. Multiple values are separated by comma,
1628 <code>none
</code> resets previous values,
<code>default
</code> reset the list to
1629 <code>new
</code> and
<code>all
</code> is a shorthand for
<code>old,new,context
</code>. When
1630 this option is not given, and the configuration variable
1631 <code>diff.wsErrorHighlight
</code> is not set, only whitespace errors in
1632 <code>new
</code> lines are highlighted. The whitespace errors are colored
1633 with
<code>color.diff.whitespace
</code>.
1636 <dt class=
"hdlist1">
1641 Instead of the first handful of characters, show the full
1642 pre- and post-image blob object names on the
"index"
1643 line when generating patch format output.
1646 <dt class=
"hdlist1">
1651 In addition to
<code>--full-index
</code>, output a binary diff that
1652 can be applied with
<code>git-apply
</code>.
1653 Implies
<code>--patch
</code>.
1656 <dt class=
"hdlist1">
1657 --abbrev[=
<n
>]
1661 Instead of showing the full
40-byte hexadecimal object
1662 name in diff-raw format output and diff-tree header
1663 lines, show the shortest prefix that is at least
<em><n
></em>
1664 hexdigits long that uniquely refers the object.
1665 In diff-patch output format,
<code>--full-index
</code> takes higher
1666 precedence, i.e. if
<code>--full-index
</code> is specified, full blob
1667 names will be shown regardless of
<code>--abbrev
</code>.
1668 Non default number of digits can be specified with
<code>--abbrev=
<n
></code>.
1671 <dt class=
"hdlist1">
1672 -B[
<n
>][/
<m
>]
1674 <dt class=
"hdlist1">
1675 --break-rewrites[=[
<n
>][/
<m
>]]
1679 Break complete rewrite changes into pairs of delete and
1680 create. This serves two purposes:
1682 <div class=
"paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1683 not as a series of deletion and insertion mixed together with a very
1684 few lines that happen to match textually as the context, but as a
1685 single deletion of everything old followed by a single insertion of
1686 everything new, and the number
<code>m
</code> controls this aspect of the -B
1687 option (defaults to
60%).
<code>-B/
70%
</code> specifies that less than
30% of the
1688 original should remain in the result for Git to consider it a total
1689 rewrite (i.e. otherwise the resulting patch will be a series of
1690 deletion and insertion mixed together with context lines).
</p></div>
1691 <div class=
"paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1692 source of a rename (usually -M only considers a file that disappeared
1693 as the source of a rename), and the number
<code>n
</code> controls this aspect of
1694 the -B option (defaults to
50%).
<code>-B20%
</code> specifies that a change with
1695 addition and deletion compared to
20% or more of the file
’s size are
1696 eligible for being picked up as a possible source of a rename to
1697 another file.
</p></div>
1699 <dt class=
"hdlist1">
1702 <dt class=
"hdlist1">
1703 --find-renames[=
<n
>]
1708 If
<code>n
</code> is specified, it is a threshold on the similarity
1709 index (i.e. amount of addition/deletions compared to the
1710 file
’s size). For example,
<code>-M90%
</code> means Git should consider a
1711 delete/add pair to be a rename if more than
90% of the file
1712 hasn
’t changed. Without a
<code>%
</code> sign, the number is to be read as
1713 a fraction, with a decimal point before it. I.e.,
<code>-M5
</code> becomes
1714 0.5, and is thus the same as
<code>-M50%
</code>. Similarly,
<code>-M05
</code> is
1715 the same as
<code>-M5%
</code>. To limit detection to exact renames, use
1716 <code>-M100%
</code>. The default similarity index is
50%.
1719 <dt class=
"hdlist1">
1722 <dt class=
"hdlist1">
1723 --find-copies[=
<n
>]
1727 Detect copies as well as renames. See also
<code>--find-copies-harder
</code>.
1728 If
<code>n
</code> is specified, it has the same meaning as for
<code>-M
<n
></code>.
1731 <dt class=
"hdlist1">
1732 --find-copies-harder
1736 For performance reasons, by default,
<code>-C
</code> option finds copies only
1737 if the original file of the copy was modified in the same
1738 changeset. This flag makes the command
1739 inspect unmodified files as candidates for the source of
1740 copy. This is a very expensive operation for large
1741 projects, so use it with caution. Giving more than one
1742 <code>-C
</code> option has the same effect.
1745 <dt class=
"hdlist1">
1748 <dt class=
"hdlist1">
1749 --irreversible-delete
1753 Omit the preimage for deletes, i.e. print only the header but not
1754 the diff between the preimage and
<code>/dev/null
</code>. The resulting patch
1755 is not meant to be applied with
<code>patch
</code> or
<code>git apply
</code>; this is
1756 solely for people who want to just concentrate on reviewing the
1757 text after the change. In addition, the output obviously lacks
1758 enough information to apply such a patch in reverse, even manually,
1759 hence the name of the option.
1761 <div class=
"paragraph"><p>When used together with
<code>-B
</code>, omit also the preimage in the deletion part
1762 of a delete/create pair.
</p></div>
1764 <dt class=
"hdlist1">
1769 The
<code>-M
</code> and
<code>-C
</code> options involve some preliminary steps that
1770 can detect subsets of renames/copies cheaply, followed by an
1771 exhaustive fallback portion that compares all remaining
1772 unpaired destinations to all relevant sources. (For renames,
1773 only remaining unpaired sources are relevant; for copies, all
1774 original sources are relevant.) For N sources and
1775 destinations, this exhaustive check is O(N^
2). This option
1776 prevents the exhaustive portion of rename/copy detection from
1777 running if the number of source/destination files involved
1778 exceeds the specified number. Defaults to diff.renameLimit.
1779 Note that a value of
0 is treated as unlimited.
1782 <dt class=
"hdlist1">
1783 --diff-filter=[(A|C|D|M|R|T|U|X|B)
…[*]]
1787 Select only files that are Added (
<code>A
</code>), Copied (
<code>C
</code>),
1788 Deleted (
<code>D
</code>), Modified (
<code>M
</code>), Renamed (
<code>R
</code>), have their
1789 type (i.e. regular file, symlink, submodule,
…) changed (
<code>T
</code>),
1790 are Unmerged (
<code>U
</code>), are
1791 Unknown (
<code>X
</code>), or have had their pairing Broken (
<code>B
</code>).
1792 Any combination of the filter characters (including none) can be used.
1793 When
<code>*
</code> (All-or-none) is added to the combination, all
1794 paths are selected if there is any file that matches
1795 other criteria in the comparison; if there is no file
1796 that matches other criteria, nothing is selected.
1798 <div class=
"paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1799 <code>--diff-filter=ad
</code> excludes added and deleted paths.
</p></div>
1800 <div class=
"paragraph"><p>Note that not all diffs can feature all types. For instance, copied and
1801 renamed entries cannot appear if detection for those types is disabled.
</p></div>
1803 <dt class=
"hdlist1">
1808 Look for differences that change the number of occurrences of
1809 the specified string (i.e. addition/deletion) in a file.
1810 Intended for the scripter
’s use.
1812 <div class=
"paragraph"><p>It is useful when you
’re looking for an exact block of code (like a
1813 struct), and want to know the history of that block since it first
1814 came into being: use the feature iteratively to feed the interesting
1815 block in the preimage back into
<code>-S
</code>, and keep going until you get the
1816 very first version of the block.
</p></div>
1817 <div class=
"paragraph"><p>Binary files are searched as well.
</p></div>
1819 <dt class=
"hdlist1">
1824 Look for differences whose patch text contains added/removed
1825 lines that match
<regex
>.
1827 <div class=
"paragraph"><p>To illustrate the difference between
<code>-S
<regex
> --pickaxe-regex
</code> and
1828 <code>-G
<regex
></code>, consider a commit with the following diff in the same
1830 <div class=
"listingblock">
1831 <div class=
"content">
1832 <pre><code>+ return frotz(nitfol, two-
>ptr,
1,
0);
1834 - hit = frotz(nitfol, mf2.ptr,
1,
0);
</code></pre>
1836 <div class=
"paragraph"><p>While
<code>git log -G
"frotz\(nitfol"</code> will show this commit,
<code>git log
1837 -S
"frotz\(nitfol" --pickaxe-regex
</code> will not (because the number of
1838 occurrences of that string did not change).
</p></div>
1839 <div class=
"paragraph"><p>Unless
<code>--text
</code> is supplied patches of binary files without a textconv
1840 filter will be ignored.
</p></div>
1841 <div class=
"paragraph"><p>See the
<em>pickaxe
</em> entry in
<a href=
"gitdiffcore.html">gitdiffcore(
7)
</a> for more
1842 information.
</p></div>
1844 <dt class=
"hdlist1">
1845 --find-object=
<object-id
>
1849 Look for differences that change the number of occurrences of
1850 the specified object. Similar to
<code>-S
</code>, just the argument is different
1851 in that it doesn
’t search for a specific string but for a specific
1854 <div class=
"paragraph"><p>The object can be a blob or a submodule commit. It implies the
<code>-t
</code> option in
1855 <code>git-log
</code> to also find trees.
</p></div>
1857 <dt class=
"hdlist1">
1862 When
<code>-S
</code> or
<code>-G
</code> finds a change, show all the changes in that
1863 changeset, not just the files that contain the change
1867 <dt class=
"hdlist1">
1872 Treat the
<string
> given to
<code>-S
</code> as an extended POSIX regular
1873 expression to match.
1876 <dt class=
"hdlist1">
1881 Control the order in which files appear in the output.
1882 This overrides the
<code>diff.orderFile
</code> configuration variable
1883 (see
<a href=
"git-config.html">git-config(
1)
</a>). To cancel
<code>diff.orderFile
</code>,
1884 use
<code>-O/dev/null
</code>.
1886 <div class=
"paragraph"><p>The output order is determined by the order of glob patterns in
1888 All files with pathnames that match the first pattern are output
1889 first, all files with pathnames that match the second pattern (but not
1890 the first) are output next, and so on.
1891 All files with pathnames that do not match any pattern are output
1892 last, as if there was an implicit match-all pattern at the end of the
1894 If multiple pathnames have the same rank (they match the same pattern
1895 but no earlier patterns), their output order relative to each other is
1896 the normal order.
</p></div>
1897 <div class=
"paragraph"><p><orderfile
> is parsed as follows:
</p></div>
1898 <div class=
"openblock">
1899 <div class=
"content">
1900 <div class=
"ulist"><ul>
1903 Blank lines are ignored, so they can be used as separators for
1909 Lines starting with a hash (
"<code>#</code>") are ignored, so they can be used
1910 for comments. Add a backslash (
"<code>\</code>") to the beginning of the
1911 pattern if it starts with a hash.
1916 Each other line contains a single pattern.
1921 <div class=
"paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1922 fnmatch(
3) without the FNM_PATHNAME flag, except a pathname also
1923 matches a pattern if removing any number of the final pathname
1924 components matches the pattern. For example, the pattern
"<code>foo*bar</code>"
1925 matches
"<code>fooasdfbar</code>" and
"<code>foo/bar/baz/asdf</code>" but not
"<code>foobarx</code>".
</p></div>
1927 <dt class=
"hdlist1">
1928 --skip-to=
<file
>
1930 <dt class=
"hdlist1">
1931 --rotate-to=
<file
>
1935 Discard the files before the named
<file
> from the output
1936 (i.e.
<em>skip to
</em>), or move them to the end of the output
1937 (i.e.
<em>rotate to
</em>). These options were invented primarily for the use
1938 of the
<code>git difftool
</code> command, and may not be very useful
1942 <dt class=
"hdlist1">
1947 Swap two inputs; that is, show differences from index or
1948 on-disk file to tree contents.
1951 <dt class=
"hdlist1">
1952 --relative[=
<path
>]
1954 <dt class=
"hdlist1">
1959 When run from a subdirectory of the project, it can be
1960 told to exclude changes outside the directory and show
1961 pathnames relative to it with this option. When you are
1962 not in a subdirectory (e.g. in a bare repository), you
1963 can name which subdirectory to make the output relative
1964 to by giving a
<path
> as an argument.
1965 <code>--no-relative
</code> can be used to countermand both
<code>diff.relative
</code> config
1966 option and previous
<code>--relative
</code>.
1969 <dt class=
"hdlist1">
1972 <dt class=
"hdlist1">
1977 Treat all files as text.
1980 <dt class=
"hdlist1">
1985 Ignore carriage-return at the end of line when doing a comparison.
1988 <dt class=
"hdlist1">
1989 --ignore-space-at-eol
1993 Ignore changes in whitespace at EOL.
1996 <dt class=
"hdlist1">
1999 <dt class=
"hdlist1">
2000 --ignore-space-change
2004 Ignore changes in amount of whitespace. This ignores whitespace
2005 at line end, and considers all other sequences of one or
2006 more whitespace characters to be equivalent.
2009 <dt class=
"hdlist1">
2012 <dt class=
"hdlist1">
2017 Ignore whitespace when comparing lines. This ignores
2018 differences even if one line has whitespace where the other
2022 <dt class=
"hdlist1">
2023 --ignore-blank-lines
2027 Ignore changes whose lines are all blank.
2030 <dt class=
"hdlist1">
2033 <dt class=
"hdlist1">
2034 --ignore-matching-lines=
<regex
>
2038 Ignore changes whose all lines match
<regex
>. This option may
2039 be specified more than once.
2042 <dt class=
"hdlist1">
2043 --inter-hunk-context=
<lines
>
2047 Show the context between diff hunks, up to the specified number
2048 of lines, thereby fusing hunks that are close to each other.
2049 Defaults to
<code>diff.interHunkContext
</code> or
0 if the config option
2053 <dt class=
"hdlist1">
2056 <dt class=
"hdlist1">
2061 Show whole function as context lines for each change.
2062 The function names are determined in the same way as
2063 <code>git diff
</code> works out patch hunk headers (see
<em>Defining a
2064 custom hunk-header
</em> in
<a href=
"gitattributes.html">gitattributes(
5)
</a>).
2067 <dt class=
"hdlist1">
2072 Make the program exit with codes similar to diff(
1).
2073 That is, it exits with
1 if there were differences and
2074 0 means no differences.
2077 <dt class=
"hdlist1">
2082 Disable all output of the program. Implies
<code>--exit-code
</code>.
2085 <dt class=
"hdlist1">
2090 Allow an external diff helper to be executed. If you set an
2091 external diff driver with
<a href=
"gitattributes.html">gitattributes(
5)
</a>, you need
2092 to use this option with
<a href=
"git-log.html">git-log(
1)
</a> and friends.
2095 <dt class=
"hdlist1">
2100 Disallow external diff drivers.
2103 <dt class=
"hdlist1">
2106 <dt class=
"hdlist1">
2111 Allow (or disallow) external text conversion filters to be run
2112 when comparing binary files. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for
2113 details. Because textconv filters are typically a one-way
2114 conversion, the resulting diff is suitable for human
2115 consumption, but cannot be applied. For this reason, textconv
2116 filters are enabled by default only for
<a href=
"git-diff.html">git-diff(
1)
</a> and
2117 <a href=
"git-log.html">git-log(
1)
</a>, but not for
<a href=
"git-format-patch.html">git-format-patch(
1)
</a> or
2118 diff plumbing commands.
2121 <dt class=
"hdlist1">
2122 --ignore-submodules[=
<when
>]
2126 Ignore changes to submodules in the diff generation.
<when
> can be
2127 either
"none",
"untracked",
"dirty" or
"all", which is the default.
2128 Using
"none" will consider the submodule modified when it either contains
2129 untracked or modified files or its HEAD differs from the commit recorded
2130 in the superproject and can be used to override any settings of the
2131 <em>ignore
</em> option in
<a href=
"git-config.html">git-config(
1)
</a> or
<a href=
"gitmodules.html">gitmodules(
5)
</a>. When
2132 "untracked" is used submodules are not considered dirty when they only
2133 contain untracked content (but they are still scanned for modified
2134 content). Using
"dirty" ignores all changes to the work tree of submodules,
2135 only changes to the commits stored in the superproject are shown (this was
2136 the behavior until
1.7.0). Using
"all" hides all changes to submodules.
2139 <dt class=
"hdlist1">
2140 --src-prefix=
<prefix
>
2144 Show the given source prefix instead of
"a/".
2147 <dt class=
"hdlist1">
2148 --dst-prefix=
<prefix
>
2152 Show the given destination prefix instead of
"b/".
2155 <dt class=
"hdlist1">
2160 Do not show any source or destination prefix.
2163 <dt class=
"hdlist1">
2168 Use the default source and destination prefixes (
"a/" and
"b/").
2169 This is usually the default already, but may be used to override
2170 config such as
<code>diff.noprefix
</code>.
2173 <dt class=
"hdlist1">
2174 --line-prefix=
<prefix
>
2178 Prepend an additional prefix to every line of output.
2181 <dt class=
"hdlist1">
2182 --ita-invisible-in-index
2186 By default entries added by
"git add -N" appear as an existing
2187 empty file in
"git diff" and a new file in
"git diff --cached".
2188 This option makes the entry appear as a new file in
"git diff"
2189 and non-existent in
"git diff --cached". This option could be
2190 reverted with
<code>--ita-visible-in-index
</code>. Both options are
2191 experimental and could be removed in future.
2195 <div class=
"paragraph"><p>For more detailed explanation on these common options, see also
2196 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a>.
</p></div>
2197 <div class=
"dlist"><dl>
2198 <dt class=
"hdlist1">
2201 <dt class=
"hdlist1">
2204 <dt class=
"hdlist1">
2209 Compare the working tree with the
"base" version (stage #
1),
2210 "our branch" (stage #
2) or
"their branch" (stage #
3). The
2211 index contains these stages only for unmerged entries i.e.
2212 while resolving conflicts. See
<a href=
"git-read-tree.html">git-read-tree(
1)
</a>
2213 section
"3-Way Merge" for detailed information.
2216 <dt class=
"hdlist1">
2221 Omit diff output for unmerged entries and just show
2222 "Unmerged". Can be used only when comparing the working tree
2226 <dt class=
"hdlist1">
2231 The
<paths
> parameters, when given, are used to limit
2232 the diff to the named paths (you can give directory
2233 names and get diff for all files under them).
2240 <h2 id=
"_raw_output_format">Raw output format
</h2>
2241 <div class=
"sectionbody">
2242 <div class=
"paragraph"><p>The raw output format from
"git-diff-index",
"git-diff-tree",
2243 "git-diff-files" and
"git diff --raw" are very similar.
</p></div>
2244 <div class=
"paragraph"><p>These commands all compare two sets of things; what is
2245 compared differs:
</p></div>
2246 <div class=
"dlist"><dl>
2247 <dt class=
"hdlist1">
2248 git-diff-index
<tree-ish
>
2252 compares the
<tree-ish
> and the files on the filesystem.
2255 <dt class=
"hdlist1">
2256 git-diff-index --cached
<tree-ish
>
2260 compares the
<tree-ish
> and the index.
2263 <dt class=
"hdlist1">
2264 git-diff-tree [-r]
<tree-ish-
1> <tree-ish-
2> [
<pattern
>…]
2268 compares the trees named by the two arguments.
2271 <dt class=
"hdlist1">
2272 git-diff-files [
<pattern
>…]
2276 compares the index and the files on the filesystem.
2280 <div class=
"paragraph"><p>The
"git-diff-tree" command begins its output by printing the hash of
2281 what is being compared. After that, all the commands print one output
2282 line per changed file.
</p></div>
2283 <div class=
"paragraph"><p>An output line is formatted this way:
</p></div>
2284 <div class=
"listingblock">
2285 <div class=
"content">
2286 <pre><code>in-place edit :
100644 100644 bcd1234
0123456 M file0
2287 copy-edit :
100644 100644 abcd123
1234567 C68 file1 file2
2288 rename-edit :
100644 100644 abcd123
1234567 R86 file1 file3
2289 create :
000000 100644 0000000 1234567 A file4
2290 delete :
100644 000000 1234567 0000000 D file5
2291 unmerged :
000000 000000 0000000 0000000 U file6
</code></pre>
2293 <div class=
"paragraph"><p>That is, from the left to the right:
</p></div>
2294 <div class=
"olist arabic"><ol class=
"arabic">
2302 mode for
"src";
000000 if creation or unmerged.
2312 mode for
"dst";
000000 if deletion or unmerged.
2322 sha1 for
"src";
0{
40} if creation or unmerged.
2332 sha1 for
"dst";
0{
40} if deletion, unmerged or
"work tree out of sync with the index".
2342 status, followed by optional
"score" number.
2347 a tab or a NUL when
<code>-z
</code> option is used.
2357 a tab or a NUL when
<code>-z
</code> option is used; only exists for C or R.
2362 path for
"dst"; only exists for C or R.
2367 an LF or a NUL when
<code>-z
</code> option is used, to terminate the record.
2371 <div class=
"paragraph"><p>Possible status letters are:
</p></div>
2372 <div class=
"ulist"><ul>
2375 A: addition of a file
2380 C: copy of a file into a new one
2385 D: deletion of a file
2390 M: modification of the contents or mode of a file
2395 R: renaming of a file
2400 T: change in the type of the file (regular file, symbolic link or submodule)
2405 U: file is unmerged (you must complete the merge before it can
2411 X:
"unknown" change type (most probably a bug, please report it)
2415 <div class=
"paragraph"><p>Status letters C and R are always followed by a score (denoting the
2416 percentage of similarity between the source and target of the move or
2417 copy). Status letter M may be followed by a score (denoting the
2418 percentage of dissimilarity) for file rewrites.
</p></div>
2419 <div class=
"paragraph"><p>The sha1 for
"dst" is shown as all
0’s if a file on the filesystem
2420 is out of sync with the index.
</p></div>
2421 <div class=
"paragraph"><p>Example:
</p></div>
2422 <div class=
"listingblock">
2423 <div class=
"content">
2424 <pre><code>:
100644 100644 5be4a4a
0000000 M file.c
</code></pre>
2426 <div class=
"paragraph"><p>Without the
<code>-z
</code> option, pathnames with
"unusual" characters are
2427 quoted as explained for the configuration variable
<code>core.quotePath
</code>
2428 (see
<a href=
"git-config.html">git-config(
1)
</a>). Using
<code>-z
</code> the filename is output
2429 verbatim and the line is terminated by a NUL byte.
</p></div>
2433 <h2 id=
"_diff_format_for_merges">diff format for merges
</h2>
2434 <div class=
"sectionbody">
2435 <div class=
"paragraph"><p>"git-diff-tree",
"git-diff-files" and
"git-diff --raw"
2436 can take
<code>-c
</code> or
<code>--cc
</code> option
2437 to generate diff output also for merge commits. The output differs
2438 from the format described above in the following way:
</p></div>
2439 <div class=
"olist arabic"><ol class=
"arabic">
2442 there is a colon for each parent
2447 there are more
"src" modes and
"src" sha1
2452 status is concatenated status characters for each parent
2457 no optional
"score" number
2462 tab-separated pathname(s) of the file
2466 <div class=
"paragraph"><p>For
<code>-c
</code> and
<code>--cc
</code>, only the destination or final path is shown even
2467 if the file was renamed on any side of history. With
2468 <code>--combined-all-paths
</code>, the name of the path in each parent is shown
2469 followed by the name of the path in the merge commit.
</p></div>
2470 <div class=
"paragraph"><p>Examples for
<code>-c
</code> and
<code>--cc
</code> without
<code>--combined-all-paths
</code>:
</p></div>
2471 <div class=
"listingblock">
2472 <div class=
"content">
2473 <pre><code>::
100644 100644 100644 fabadb8 cc95eb0
4866510 MM desc.c
2474 ::
100755 100755 100755 52b7a2d
6d1ac04 d2ac7d7 RM bar.sh
2475 ::
100644 100644 100644 e07d6c5
9042e82 ee91881 RR phooey.c
</code></pre>
2477 <div class=
"paragraph"><p>Examples when
<code>--combined-all-paths
</code> added to either
<code>-c
</code> or
<code>--cc
</code>:
</p></div>
2478 <div class=
"listingblock">
2479 <div class=
"content">
2480 <pre><code>::
100644 100644 100644 fabadb8 cc95eb0
4866510 MM desc.c desc.c desc.c
2481 ::
100755 100755 100755 52b7a2d
6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
2482 ::
100644 100644 100644 e07d6c5
9042e82 ee91881 RR fooey.c fuey.c phooey.c
</code></pre>
2484 <div class=
"paragraph"><p>Note that
<em>combined diff
</em> lists only files which were modified from
2485 all parents.
</p></div>
2489 <h2 id=
"generate_patch_text_with_p">Generating patch text with -p
</h2>
2490 <div class=
"sectionbody">
2491 <div class=
"paragraph"><p>Running
2492 <a href=
"git-diff.html">git-diff(
1)
</a>,
2493 <a href=
"git-log.html">git-log(
1)
</a>,
2494 <a href=
"git-show.html">git-show(
1)
</a>,
2495 <a href=
"git-diff-index.html">git-diff-index(
1)
</a>,
2496 <a href=
"git-diff-tree.html">git-diff-tree(
1)
</a>, or
2497 <a href=
"git-diff-files.html">git-diff-files(
1)
</a>
2498 with the
<code>-p
</code> option produces patch text.
2499 You can customize the creation of patch text via the
2500 <code>GIT_EXTERNAL_DIFF
</code> and the
<code>GIT_DIFF_OPTS
</code> environment variables
2501 (see
<a href=
"git.html">git(
1)
</a>), and the
<code>diff
</code> attribute (see
<a href=
"gitattributes.html">gitattributes(
5)
</a>).
</p></div>
2502 <div class=
"paragraph"><p>What the -p option produces is slightly different from the traditional
2503 diff format:
</p></div>
2504 <div class=
"olist arabic"><ol class=
"arabic">
2507 It is preceded by a
"git diff" header that looks like this:
2509 <div class=
"literalblock">
2510 <div class=
"content">
2511 <pre><code>diff --git a/file1 b/file2
</code></pre>
2513 <div class=
"paragraph"><p>The
<code>a/
</code> and
<code>b/
</code> filenames are the same unless rename/copy is
2514 involved. Especially, even for a creation or a deletion,
2515 <code>/dev/null
</code> is
<em>not
</em> used in place of the
<code>a/
</code> or
<code>b/
</code> filenames.
</p></div>
2516 <div class=
"paragraph"><p>When a rename/copy is involved,
<code>file1
</code> and
<code>file2
</code> show the
2517 name of the source file of the rename/copy and the name of
2518 the file that the rename/copy produces, respectively.
</p></div>
2522 It is followed by one or more extended header lines:
2524 <div class=
"literalblock">
2525 <div class=
"content">
2526 <pre><code>old mode
<mode
>
2527 new mode
<mode
>
2528 deleted file mode
<mode
>
2529 new file mode
<mode
>
2530 copy from
<path
>
2531 copy to
<path
>
2532 rename from
<path
>
2533 rename to
<path
>
2534 similarity index
<number
>
2535 dissimilarity index
<number
>
2536 index
<hash
>..
<hash
> <mode
></code></pre>
2538 <div class=
"paragraph"><p>File modes are printed as
6-digit octal numbers including the file type
2539 and file permission bits.
</p></div>
2540 <div class=
"paragraph"><p>Path names in extended headers do not include the
<code>a/
</code> and
<code>b/
</code> prefixes.
</p></div>
2541 <div class=
"paragraph"><p>The similarity index is the percentage of unchanged lines, and
2542 the dissimilarity index is the percentage of changed lines. It
2543 is a rounded down integer, followed by a percent sign. The
2544 similarity index value of
100% is thus reserved for two equal
2545 files, while
100% dissimilarity means that no line from the old
2546 file made it into the new one.
</p></div>
2547 <div class=
"paragraph"><p>The index line includes the blob object names before and after the change.
2548 The
<mode
> is included if the file mode does not change; otherwise,
2549 separate lines indicate the old and the new mode.
</p></div>
2553 Pathnames with
"unusual" characters are quoted as explained for
2554 the configuration variable
<code>core.quotePath
</code> (see
2555 <a href=
"git-config.html">git-config(
1)
</a>).
2560 All the
<code>file1
</code> files in the output refer to files before the
2561 commit, and all the
<code>file2
</code> files refer to files after the commit.
2562 It is incorrect to apply each change to each file sequentially. For
2563 example, this patch will swap a and b:
2565 <div class=
"literalblock">
2566 <div class=
"content">
2567 <pre><code>diff --git a/a b/b
2572 rename to a
</code></pre>
2577 Hunk headers mention the name of the function to which the hunk
2578 applies. See
"Defining a custom hunk-header" in
2579 <a href=
"gitattributes.html">gitattributes(
5)
</a> for details of how to tailor this to
2587 <h2 id=
"_combined_diff_format">Combined diff format
</h2>
2588 <div class=
"sectionbody">
2589 <div class=
"paragraph"><p>Any diff-generating command can take the
<code>-c
</code> or
<code>--cc
</code> option to
2590 produce a
<em>combined diff
</em> when showing a merge. This is the default
2591 format when showing merges with
<a href=
"git-diff.html">git-diff(
1)
</a> or
2592 <a href=
"git-show.html">git-show(
1)
</a>. Note also that you can give suitable
2593 <code>--diff-merges
</code> option to any of these commands to force generation of
2594 diffs in a specific format.
</p></div>
2595 <div class=
"paragraph"><p>A
"combined diff" format looks like this:
</p></div>
2596 <div class=
"listingblock">
2597 <div class=
"content">
2598 <pre><code>diff --combined describe.c
2599 index fabadb8,cc95eb0.
.4866510
2602 @@@ -
98,
20 -
98,
12 +
98,
20 @@@
2603 return (a_date
> b_date) ? -
1 : (a_date == b_date) ?
0 :
1;
2606 - static void describe(char *arg)
2607 -static void describe(struct commit *cmit, int last_one)
2608 ++static void describe(char *arg, int last_one)
2610 + unsigned char sha1[
20];
2611 + struct commit *cmit;
2612 struct commit_list *list;
2613 static int initialized =
0;
2614 struct commit_name *n;
2616 + if (get_sha1(arg, sha1)
< 0)
2617 + usage(describe_usage);
2618 + cmit = lookup_commit_reference(sha1);
2620 + usage(describe_usage);
2624 for_each_ref(get_name);
</code></pre>
2626 <div class=
"olist arabic"><ol class=
"arabic">
2629 It is preceded by a
"git diff" header, that looks like
2630 this (when the
<code>-c
</code> option is used):
2632 <div class=
"literalblock">
2633 <div class=
"content">
2634 <pre><code>diff --combined file
</code></pre>
2636 <div class=
"paragraph"><p>or like this (when the
<code>--cc
</code> option is used):
</p></div>
2637 <div class=
"literalblock">
2638 <div class=
"content">
2639 <pre><code>diff --cc file
</code></pre>
2644 It is followed by one or more extended header lines
2645 (this example shows a merge with two parents):
2647 <div class=
"literalblock">
2648 <div class=
"content">
2649 <pre><code>index
<hash
>,
<hash
>..
<hash
>
2650 mode
<mode
>,
<mode
>..
<mode
>
2651 new file mode
<mode
>
2652 deleted file mode
<mode
>,
<mode
></code></pre>
2654 <div class=
"paragraph"><p>The
<code>mode
<mode
>,
<mode
>..
<mode
></code> line appears only if at least one of
2655 the
<mode
> is different from the rest. Extended headers with
2656 information about detected content movement (renames and
2657 copying detection) are designed to work with the diff of two
2658 <tree-ish
> and are not used by combined diff format.
</p></div>
2662 It is followed by a two-line from-file/to-file header:
2664 <div class=
"literalblock">
2665 <div class=
"content">
2666 <pre><code>--- a/file
2667 +++ b/file
</code></pre>
2669 <div class=
"paragraph"><p>Similar to the two-line header for the traditional
<em>unified
</em> diff
2670 format,
<code>/dev/null
</code> is used to signal created or deleted
2672 <div class=
"paragraph"><p>However, if the --combined-all-paths option is provided, instead of a
2673 two-line from-file/to-file, you get an N+
1 line from-file/to-file header,
2674 where N is the number of parents in the merge commit:
</p></div>
2675 <div class=
"literalblock">
2676 <div class=
"content">
2677 <pre><code>--- a/file
2680 +++ b/file
</code></pre>
2682 <div class=
"paragraph"><p>This extended format can be useful if rename or copy detection is
2683 active, to allow you to see the original name of the file in different
2688 Chunk header format is modified to prevent people from
2689 accidentally feeding it to
<code>patch -p1
</code>. Combined diff format
2690 was created for review of merge commit changes, and was not
2691 meant to be applied. The change is similar to the change in the
2692 extended
<em>index
</em> header:
2694 <div class=
"literalblock">
2695 <div class=
"content">
2696 <pre><code>@@@
<from-file-range
> <from-file-range
> <to-file-range
> @@@
</code></pre>
2698 <div class=
"paragraph"><p>There are (number of parents +
1)
<code>@
</code> characters in the chunk
2699 header for combined diff format.
</p></div>
2702 <div class=
"paragraph"><p>Unlike the traditional
<em>unified
</em> diff format, which shows two
2703 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
2704 added to B), or
<code>" "</code> (space
 — unchanged) prefix, this format
2705 compares two or more files file1, file2,
… with one file X, and
2706 shows how X differs from each of fileN. One column for each of
2707 fileN is prepended to the output line to note how X
’s line is
2708 different from it.
</p></div>
2709 <div class=
"paragraph"><p>A
<code>-
</code> character in the column N means that the line appears in
2710 fileN but it does not appear in the result. A
<code>+
</code> character
2711 in the column N means that the line appears in the result,
2712 and fileN does not have that line (in other words, the line was
2713 added, from the point of view of that parent).
</p></div>
2714 <div class=
"paragraph"><p>In the above example output, the function signature was changed
2715 from both files (hence two
<code>-
</code> removals from both file1 and
2716 file2, plus
<code>++
</code> to mean one line that was added does not appear
2717 in either file1 or file2). Also, eight other lines are the same
2718 from file1 but do not appear in file2 (hence prefixed with
<code>+
</code>).
</p></div>
2719 <div class=
"paragraph"><p>When shown by
<code>git diff-tree -c
</code>, it compares the parents of a
2720 merge commit with the merge result (i.e. file1..fileN are the
2721 parents). When shown by
<code>git diff-files -c
</code>, it compares the
2722 two unresolved merge parents with the working tree file
2723 (i.e. file1 is stage
2 aka
"our version", file2 is stage
3 aka
2724 "their version").
</p></div>
2728 <h2 id=
"_other_diff_formats">other diff formats
</h2>
2729 <div class=
"sectionbody">
2730 <div class=
"paragraph"><p>The
<code>--summary
</code> option describes newly added, deleted, renamed and
2731 copied files. The
<code>--stat
</code> option adds diffstat(
1) graph to the
2732 output. These options can be combined with other options, such as
2733 <code>-p
</code>, and are meant for human consumption.
</p></div>
2734 <div class=
"paragraph"><p>When showing a change that involves a rename or a copy,
<code>--stat
</code> output
2735 formats the pathnames compactly by combining common prefix and suffix of
2736 the pathnames. For example, a change that moves
<code>arch/i386/Makefile
</code> to
2737 <code>arch/x86/Makefile
</code> while modifying
4 lines will be shown like this:
</p></div>
2738 <div class=
"listingblock">
2739 <div class=
"content">
2740 <pre><code>arch/{i386 =
> x86}/Makefile |
4 +--
</code></pre>
2742 <div class=
"paragraph"><p>The
<code>--numstat
</code> option gives the diffstat(
1) information but is designed
2743 for easier machine consumption. An entry in
<code>--numstat
</code> output looks
2744 like this:
</p></div>
2745 <div class=
"listingblock">
2746 <div class=
"content">
2747 <pre><code>1 2 README
2748 3 1 arch/{i386 =
> x86}/Makefile
</code></pre>
2750 <div class=
"paragraph"><p>That is, from left to right:
</p></div>
2751 <div class=
"olist arabic"><ol class=
"arabic">
2754 the number of added lines;
2764 the number of deleted lines;
2774 pathname (possibly with rename/copy information);
2783 <div class=
"paragraph"><p>When
<code>-z
</code> output option is in effect, the output is formatted this way:
</p></div>
2784 <div class=
"listingblock">
2785 <div class=
"content">
2786 <pre><code>1 2 README NUL
2787 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
</code></pre>
2789 <div class=
"paragraph"><p>That is:
</p></div>
2790 <div class=
"olist arabic"><ol class=
"arabic">
2793 the number of added lines;
2803 the number of deleted lines;
2813 a NUL (only exists if renamed/copied);
2818 pathname in preimage;
2823 a NUL (only exists if renamed/copied);
2828 pathname in postimage (only exists if renamed/copied);
2837 <div class=
"paragraph"><p>The extra
<code>NUL
</code> before the preimage path in renamed case is to allow
2838 scripts that read the output to tell if the current record being read is
2839 a single-path record or a rename/copy record without reading ahead.
2840 After reading added and deleted lines, reading up to
<code>NUL
</code> would yield
2841 the pathname, but if that is
<code>NUL
</code>, the record will show two paths.
</p></div>
2845 <h2 id=
"_examples">EXAMPLES
</h2>
2846 <div class=
"sectionbody">
2847 <div class=
"dlist"><dl>
2848 <dt class=
"hdlist1">
2849 Various ways to check your working tree
2852 <div class=
"listingblock">
2853 <div class=
"content">
2854 <pre><code>$ git diff
<b><1></b>
2855 $ git diff --cached
<b><2></b>
2856 $ git diff HEAD
<b><3></b>
2857 $ git diff AUTO_MERGE
<b><4></b></code></pre>
2859 <div class=
"colist arabic"><ol>
2862 Changes in the working tree not yet staged for the next commit.
2867 Changes between the index and your last commit; what you
2868 would be committing if you run
<code>git commit
</code> without
<code>-a
</code> option.
2873 Changes in the working tree since your last commit; what you
2874 would be committing if you run
<code>git commit -a
</code>
2879 Changes in the working tree you
’ve made to resolve textual
2885 <dt class=
"hdlist1">
2886 Comparing with arbitrary commits
2889 <div class=
"listingblock">
2890 <div class=
"content">
2891 <pre><code>$ git diff test
<b><1></b>
2892 $ git diff HEAD -- ./test
<b><2></b>
2893 $ git diff HEAD^ HEAD
<b><3></b></code></pre>
2895 <div class=
"colist arabic"><ol>
2898 Instead of using the tip of the current branch, compare with the
2899 tip of
"test" branch.
2904 Instead of comparing with the tip of
"test" branch, compare with
2905 the tip of the current branch, but limit the comparison to the
2911 Compare the version before the last commit and the last commit.
2916 <dt class=
"hdlist1">
2920 <div class=
"listingblock">
2921 <div class=
"content">
2922 <pre><code>$ git diff topic master
<b><1></b>
2923 $ git diff topic..master
<b><2></b>
2924 $ git diff topic...master
<b><3></b></code></pre>
2926 <div class=
"colist arabic"><ol>
2929 Changes between the tips of the topic and the master branches.
2939 Changes that occurred on the master branch since when the topic
2940 branch was started off it.
2945 <dt class=
"hdlist1">
2946 Limiting the diff output
2949 <div class=
"listingblock">
2950 <div class=
"content">
2951 <pre><code>$ git diff --diff-filter=MRC
<b><1></b>
2952 $ git diff --name-status
<b><2></b>
2953 $ git diff arch/i386 include/asm-i386
<b><3></b></code></pre>
2955 <div class=
"colist arabic"><ol>
2958 Show only modification, rename, and copy, but not addition
2964 Show only names and the nature of change, but not actual
2970 Limit diff output to named subtrees.
2975 <dt class=
"hdlist1">
2976 Munging the diff output
2979 <div class=
"listingblock">
2980 <div class=
"content">
2981 <pre><code>$ git diff --find-copies-harder -B -C
<b><1></b>
2982 $ git diff -R
<b><2></b></code></pre>
2984 <div class=
"colist arabic"><ol>
2987 Spend extra cycles to find renames, copies and complete
2988 rewrites (very expensive).
2993 Output diff in reverse.
3002 <h2 id=
"_configuration">CONFIGURATION
</h2>
3003 <div class=
"sectionbody">
3004 <div class=
"paragraph"><p>Everything below this line in this section is selectively included
3005 from the
<a href=
"git-config.html">git-config(
1)
</a> documentation. The content is the same
3006 as what
’s found there:
</p></div>
3007 <div class=
"dlist"><dl>
3008 <dt class=
"hdlist1">
3009 diff.autoRefreshIndex
3013 When using
<em>git diff
</em> to compare with work tree
3014 files, do not consider stat-only changes as changed.
3015 Instead, silently run
<code>git update-index --refresh
</code> to
3016 update the cached stat information for paths whose
3017 contents in the work tree match the contents in the
3018 index. This option defaults to true. Note that this
3019 affects only
<em>git diff
</em> Porcelain, and not lower level
3020 <em>diff
</em> commands such as
<em>git diff-files
</em>.
3023 <dt class=
"hdlist1">
3028 A comma separated list of
<code>--dirstat
</code> parameters specifying the
3029 default behavior of the
<code>--dirstat
</code> option to
<a href=
"git-diff.html">git-diff(
1)
</a>
3030 and friends. The defaults can be overridden on the command line
3031 (using
<code>--dirstat=
<param1,param2,...
></code>). The fallback defaults
3032 (when not changed by
<code>diff.dirstat
</code>) are
<code>changes,noncumulative,
3</code>.
3033 The following parameters are available:
3035 <div class=
"openblock">
3036 <div class=
"content">
3037 <div class=
"dlist"><dl>
3038 <dt class=
"hdlist1">
3039 <code>changes
</code>
3043 Compute the dirstat numbers by counting the lines that have been
3044 removed from the source, or added to the destination. This ignores
3045 the amount of pure code movements within a file. In other words,
3046 rearranging lines in a file is not counted as much as other changes.
3047 This is the default behavior when no parameter is given.
3050 <dt class=
"hdlist1">
3055 Compute the dirstat numbers by doing the regular line-based diff
3056 analysis, and summing the removed/added line counts. (For binary
3057 files, count
64-byte chunks instead, since binary files have no
3058 natural concept of lines). This is a more expensive
<code>--dirstat
</code>
3059 behavior than the
<code>changes
</code> behavior, but it does count rearranged
3060 lines within a file as much as other changes. The resulting output
3061 is consistent with what you get from the other
<code>--*stat
</code> options.
3064 <dt class=
"hdlist1">
3069 Compute the dirstat numbers by counting the number of files changed.
3070 Each changed file counts equally in the dirstat analysis. This is
3071 the computationally cheapest
<code>--dirstat
</code> behavior, since it does
3072 not have to look at the file contents at all.
3075 <dt class=
"hdlist1">
3076 <code>cumulative
</code>
3080 Count changes in a child directory for the parent directory as well.
3081 Note that when using
<code>cumulative
</code>, the sum of the percentages
3082 reported may exceed
100%. The default (non-cumulative) behavior can
3083 be specified with the
<code>noncumulative
</code> parameter.
3086 <dt class=
"hdlist1">
3091 An integer parameter specifies a cut-off percent (
3% by default).
3092 Directories contributing less than this percentage of the changes
3093 are not shown in the output.
3098 <div class=
"paragraph"><p>Example: The following will count changed files, while ignoring
3099 directories with less than
10% of the total amount of changed files,
3100 and accumulating child directory counts in the parent directories:
3101 <code>files,
10,cumulative
</code>.
</p></div>
3103 <dt class=
"hdlist1">
3108 Limit the width of the filename part in --stat output. If set, applies
3109 to all commands generating --stat output except format-patch.
3112 <dt class=
"hdlist1">
3117 Limit the width of the graph part in --stat output. If set, applies
3118 to all commands generating --stat output except format-patch.
3121 <dt class=
"hdlist1">
3126 Generate diffs with
<n
> lines of context instead of the default
3127 of
3. This value is overridden by the -U option.
3130 <dt class=
"hdlist1">
3131 diff.interHunkContext
3135 Show the context between diff hunks, up to the specified number
3136 of lines, thereby fusing the hunks that are close to each other.
3137 This value serves as the default for the
<code>--inter-hunk-context
</code>
3138 command line option.
3141 <dt class=
"hdlist1">
3146 If this config variable is set, diff generation is not
3147 performed using the internal diff machinery, but using the
3148 given command. Can be overridden with the
‘GIT_EXTERNAL_DIFF
’
3149 environment variable. The command is called with parameters
3150 as described under
"git Diffs" in
<a href=
"git.html">git(
1)
</a>. Note: if
3151 you want to use an external diff program only on a subset of
3152 your files, you might want to use
<a href=
"gitattributes.html">gitattributes(
5)
</a> instead.
3155 <dt class=
"hdlist1">
3156 diff.ignoreSubmodules
3160 Sets the default value of --ignore-submodules. Note that this
3161 affects only
<em>git diff
</em> Porcelain, and not lower level
<em>diff
</em>
3162 commands such as
<em>git diff-files
</em>.
<em>git checkout
</em>
3163 and
<em>git switch
</em> also honor
3164 this setting when reporting uncommitted changes. Setting it to
3165 <em>all
</em> disables the submodule summary normally shown by
<em>git commit
</em>
3166 and
<em>git status
</em> when
<code>status.submoduleSummary
</code> is set unless it is
3167 overridden by using the --ignore-submodules command-line option.
3168 The
<em>git submodule
</em> commands are not affected by this setting.
3169 By default this is set to untracked so that any untracked
3170 submodules are ignored.
3173 <dt class=
"hdlist1">
3178 If set,
<em>git diff
</em> uses a prefix pair that is different from the
3179 standard
"a/" and
"b/" depending on what is being compared. When
3180 this configuration is in effect, reverse diff output also swaps
3181 the order of the prefixes:
3183 <div class=
"dlist"><dl>
3184 <dt class=
"hdlist1">
3185 <code>git diff
</code>
3189 compares the (i)ndex and the (w)ork tree;
3192 <dt class=
"hdlist1">
3193 <code>git diff HEAD
</code>
3197 compares a (c)ommit and the (w)ork tree;
3200 <dt class=
"hdlist1">
3201 <code>git diff --cached
</code>
3205 compares a (c)ommit and the (i)ndex;
3208 <dt class=
"hdlist1">
3209 <code>git diff HEAD:file1 file2
</code>
3213 compares an (o)bject and a (w)ork tree entity;
3216 <dt class=
"hdlist1">
3217 <code>git diff --no-index a b
</code>
3221 compares two non-git things (
1) and (
2).
3226 <dt class=
"hdlist1">
3231 If set,
<em>git diff
</em> does not show any source or destination prefix.
3234 <dt class=
"hdlist1">
3239 If set to
<em>true
</em>,
<em>git diff
</em> does not show changes outside of the directory
3240 and show pathnames relative to the current directory.
3243 <dt class=
"hdlist1">
3248 File indicating how to order files within a diff.
3249 See the
<em>-O
</em> option to
<a href=
"git-diff.html">git-diff(
1)
</a> for details.
3250 If
<code>diff.orderFile
</code> is a relative pathname, it is treated as
3251 relative to the top of the working tree.
3254 <dt class=
"hdlist1">
3259 The number of files to consider in the exhaustive portion of
3260 copy/rename detection; equivalent to the
<em>git diff
</em> option
3261 <code>-l
</code>. If not set, the default value is currently
1000. This
3262 setting has no effect if rename detection is turned off.
3265 <dt class=
"hdlist1">
3270 Whether and how Git detects renames. If set to
"false",
3271 rename detection is disabled. If set to
"true", basic rename
3272 detection is enabled. If set to
"copies" or
"copy", Git will
3273 detect copies, as well. Defaults to true. Note that this
3274 affects only
<em>git diff
</em> Porcelain like
<a href=
"git-diff.html">git-diff(
1)
</a> and
3275 <a href=
"git-log.html">git-log(
1)
</a>, and not lower level commands such as
3276 <a href=
"git-diff-files.html">git-diff-files(
1)
</a>.
3279 <dt class=
"hdlist1">
3280 diff.suppressBlankEmpty
3284 A boolean to inhibit the standard behavior of printing a space
3285 before each empty output line. Defaults to false.
3288 <dt class=
"hdlist1">
3293 Specify the format in which differences in submodules are
3294 shown. The
"short" format just shows the names of the commits
3295 at the beginning and end of the range. The
"log" format lists
3296 the commits in the range like
<a href=
"git-submodule.html">git-submodule(
1)
</a> <code>summary
</code>
3297 does. The
"diff" format shows an inline diff of the changed
3298 contents of the submodule. Defaults to
"short".
3301 <dt class=
"hdlist1">
3306 A POSIX Extended Regular Expression used to determine what is a
"word"
3307 when performing word-by-word difference calculations. Character
3308 sequences that match the regular expression are
"words", all other
3309 characters are
<strong>ignorable
</strong> whitespace.
3312 <dt class=
"hdlist1">
3313 diff.
<driver
>.command
3317 The custom diff driver command. See
<a href=
"gitattributes.html">gitattributes(
5)
</a>
3321 <dt class=
"hdlist1">
3322 diff.
<driver
>.xfuncname
3326 The regular expression that the diff driver should use to
3327 recognize the hunk header. A built-in pattern may also be used.
3328 See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for details.
3331 <dt class=
"hdlist1">
3332 diff.
<driver
>.binary
3336 Set this option to true to make the diff driver treat files as
3337 binary. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for details.
3340 <dt class=
"hdlist1">
3341 diff.
<driver
>.textconv
3345 The command that the diff driver should call to generate the
3346 text-converted version of a file. The result of the
3347 conversion is used to generate a human-readable diff. See
3348 <a href=
"gitattributes.html">gitattributes(
5)
</a> for details.
3351 <dt class=
"hdlist1">
3352 diff.
<driver
>.wordRegex
3356 The regular expression that the diff driver should use to
3357 split words in a line. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for
3361 <dt class=
"hdlist1">
3362 diff.
<driver
>.cachetextconv
3366 Set this option to true to make the diff driver cache the text
3367 conversion outputs. See
<a href=
"gitattributes.html">gitattributes(
5)
</a> for details.
3369 <div class=
"dlist"><dl>
3370 <dt class=
"hdlist1">
3375 Use Araxis Merge (requires a graphical session)
3378 <dt class=
"hdlist1">
3383 Use Beyond Compare (requires a graphical session)
3386 <dt class=
"hdlist1">
3391 Use Beyond Compare (requires a graphical session)
3394 <dt class=
"hdlist1">
3399 Use Beyond Compare (requires a graphical session)
3402 <dt class=
"hdlist1">
3403 <code>codecompare
</code>
3407 Use Code Compare (requires a graphical session)
3410 <dt class=
"hdlist1">
3411 <code>deltawalker
</code>
3415 Use DeltaWalker (requires a graphical session)
3418 <dt class=
"hdlist1">
3419 <code>diffmerge
</code>
3423 Use DiffMerge (requires a graphical session)
3426 <dt class=
"hdlist1">
3427 <code>diffuse
</code>
3431 Use Diffuse (requires a graphical session)
3434 <dt class=
"hdlist1">
3435 <code>ecmerge
</code>
3439 Use ECMerge (requires a graphical session)
3442 <dt class=
"hdlist1">
3450 <dt class=
"hdlist1">
3451 <code>examdiff
</code>
3455 Use ExamDiff Pro (requires a graphical session)
3458 <dt class=
"hdlist1">
3463 Use Guiffy
’s Diff Tool (requires a graphical session)
3466 <dt class=
"hdlist1">
3467 <code>gvimdiff
</code>
3471 Use gVim (requires a graphical session)
3474 <dt class=
"hdlist1">
3479 Use KDiff3 (requires a graphical session)
3482 <dt class=
"hdlist1">
3483 <code>kompare
</code>
3487 Use Kompare (requires a graphical session)
3490 <dt class=
"hdlist1">
3495 Use Meld (requires a graphical session)
3498 <dt class=
"hdlist1">
3499 <code>nvimdiff
</code>
3506 <dt class=
"hdlist1">
3507 <code>opendiff
</code>
3511 Use FileMerge (requires a graphical session)
3514 <dt class=
"hdlist1">
3515 <code>p4merge
</code>
3519 Use HelixCore P4Merge (requires a graphical session)
3522 <dt class=
"hdlist1">
3527 Use Sublime Merge (requires a graphical session)
3530 <dt class=
"hdlist1">
3535 Use TkDiff (requires a graphical session)
3538 <dt class=
"hdlist1">
3539 <code>vimdiff
</code>
3546 <dt class=
"hdlist1">
3547 <code>winmerge
</code>
3551 Use WinMerge (requires a graphical session)
3554 <dt class=
"hdlist1">
3559 Use xxdiff (requires a graphical session)
3564 <dt class=
"hdlist1">
3565 diff.indentHeuristic
3569 Set this option to
<code>false
</code> to disable the default heuristics
3570 that shift diff hunk boundaries to make patches easier to read.
3573 <dt class=
"hdlist1">
3578 Choose a diff algorithm. The variants are as follows:
3580 <div class=
"openblock">
3581 <div class=
"content">
3582 <div class=
"dlist"><dl>
3583 <dt class=
"hdlist1">
3584 <code>default
</code>,
<code>myers
</code>
3588 The basic greedy diff algorithm. Currently, this is the default.
3591 <dt class=
"hdlist1">
3592 <code>minimal
</code>
3596 Spend extra time to make sure the smallest possible diff is
3600 <dt class=
"hdlist1">
3601 <code>patience
</code>
3605 Use
"patience diff" algorithm when generating patches.
3608 <dt class=
"hdlist1">
3609 <code>histogram
</code>
3613 This algorithm extends the patience algorithm to
"support
3614 low-occurrence common elements".
3620 <dt class=
"hdlist1">
3621 diff.wsErrorHighlight
3625 Highlight whitespace errors in the
<code>context
</code>,
<code>old
</code> or
<code>new
</code>
3626 lines of the diff. Multiple values are separated by comma,
3627 <code>none
</code> resets previous values,
<code>default
</code> reset the list to
3628 <code>new
</code> and
<code>all
</code> is a shorthand for
<code>old,new,context
</code>. The
3629 whitespace errors are colored with
<code>color.diff.whitespace
</code>.
3630 The command line option
<code>--ws-error-highlight=
<kind
></code>
3631 overrides this setting.
3634 <dt class=
"hdlist1">
3639 If set to either a valid
<code><mode
></code> or a true value, moved lines
3640 in a diff are colored differently, for details of valid modes
3641 see
<em>--color-moved
</em> in
<a href=
"git-diff.html">git-diff(
1)
</a>. If simply set to
3642 true the default color mode will be used. When set to false,
3643 moved lines are not colored.
3646 <dt class=
"hdlist1">
3651 When moved lines are colored using e.g. the
<code>diff.colorMoved
</code> setting,
3652 this option controls the
<code><mode
></code> how spaces are treated
3653 for details of valid modes see
<em>--color-moved-ws
</em> in
<a href=
"git-diff.html">git-diff(
1)
</a>.
3660 <h2 id=
"_see_also">SEE ALSO
</h2>
3661 <div class=
"sectionbody">
3662 <div class=
"paragraph"><p>diff(
1),
3663 <a href=
"git-difftool.html">git-difftool(
1)
</a>,
3664 <a href=
"git-log.html">git-log(
1)
</a>,
3665 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a>,
3666 <a href=
"git-format-patch.html">git-format-patch(
1)
</a>,
3667 <a href=
"git-apply.html">git-apply(
1)
</a>,
3668 <a href=
"git-show.html">git-show(
1)
</a></p></div>
3672 <h2 id=
"_git">GIT
</h2>
3673 <div class=
"sectionbody">
3674 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
3678 <div id=
"footnotes"><hr /></div>
3680 <div id=
"footer-text">
3682 2023-
12-
27 15:
50:
18 PST