1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>git-diff-index(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-diff-index(
1) Manual Page
409 <div class=
"sectionbody">
411 Compares content and mode of blobs between the index and repository
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git diff-index
</em> [-m] [--cached] [
<common diff options
>]
<tree-ish
> [
<path
>…]
</div>
419 <div class=
"verseblock-attribution">
422 <h2 id=
"_description">DESCRIPTION
</h2>
423 <div class=
"sectionbody">
424 <div class=
"paragraph"><p>Compares the content and mode of the blobs found via a tree
425 object with the content of the current index and, optionally
426 ignoring the stat state of the file on disk. When paths are
427 specified, compares only those named paths. Otherwise all
428 entries in the index are compared.
</p></div>
430 <h2 id=
"_options">OPTIONS
</h2>
431 <div class=
"sectionbody">
432 <div class=
"dlist"><dl>
444 Generate patch (see section on generating patches).
456 Generate diffs with
<n
> lines of context instead of
466 Generate the raw format.
475 Synonym for
<tt>-p --raw
</tt>.
483 Generate a diff using the
"patience diff" algorithm.
487 --stat[=
<width
>[,
<name-width
>[,
<count
>]]]
491 Generate a diffstat. You can override the default
492 output width for
80-column terminal by
<tt>--stat=
<width
></tt>.
493 The width of the filename part can be controlled by
494 giving another width to it separated by a comma.
495 By giving a third parameter
<tt><count
></tt>, you can limit the
496 output to the first
<tt><count
></tt> lines, followed by
497 <tt>…</tt> if there are more.
499 <div class=
"paragraph"><p>These parameters can also be set individually with
<tt>--stat-width=
<width
></tt>,
500 <tt>--stat-name-width=
<name-width
></tt> and
<tt>--stat-count=
<count
></tt>.
</p></div>
507 Similar to
<tt>--stat
</tt>, but shows number of added and
508 deleted lines in decimal notation and pathname without
509 abbreviation, to make it more machine friendly. For
510 binary files, outputs two
<tt>-
</tt> instead of saying
519 Output only the last line of the
<tt>--stat
</tt> format containing total
520 number of modified files, as well as number of added and deleted
525 --dirstat[=
<param1,param2,
…>]
529 Output the distribution of relative amount of changes for each
530 sub-directory. The behavior of
<tt>--dirstat
</tt> can be customized by
531 passing it a comma separated list of parameters.
532 The defaults are controlled by the
<tt>diff.dirstat
</tt> configuration
533 variable (see
<a href=
"git-config.html">git-config(
1)
</a>).
534 The following parameters are available:
536 <div class=
"dlist"><dl>
542 Compute the dirstat numbers by counting the lines that have been
543 removed from the source, or added to the destination. This ignores
544 the amount of pure code movements within a file. In other words,
545 rearranging lines in a file is not counted as much as other changes.
546 This is the default behavior when no parameter is given.
554 Compute the dirstat numbers by doing the regular line-based diff
555 analysis, and summing the removed/added line counts. (For binary
556 files, count
64-byte chunks instead, since binary files have no
557 natural concept of lines). This is a more expensive
<tt>--dirstat
</tt>
558 behavior than the
<tt>changes
</tt> behavior, but it does count rearranged
559 lines within a file as much as other changes. The resulting output
560 is consistent with what you get from the other
<tt>--*stat
</tt> options.
568 Compute the dirstat numbers by counting the number of files changed.
569 Each changed file counts equally in the dirstat analysis. This is
570 the computationally cheapest
<tt>--dirstat
</tt> behavior, since it does
571 not have to look at the file contents at all.
579 Count changes in a child directory for the parent directory as well.
580 Note that when using
<tt>cumulative
</tt>, the sum of the percentages
581 reported may exceed
100%. The default (non-cumulative) behavior can
582 be specified with the
<tt>noncumulative
</tt> parameter.
590 An integer parameter specifies a cut-off percent (
3% by default).
591 Directories contributing less than this percentage of the changes
592 are not shown in the output.
596 <div class=
"paragraph"><p>Example: The following will count changed files, while ignoring
597 directories with less than
10% of the total amount of changed files,
598 and accumulating child directory counts in the parent directories:
599 <tt>--dirstat=files,
10,cumulative
</tt>.
</p></div>
606 Output a condensed summary of extended header information
607 such as creations, renames and mode changes.
615 Synonym for
<tt>-p --stat
</tt>.
623 When
<tt>--raw
</tt>,
<tt>--numstat
</tt>,
<tt>--name-only
</tt> or
<tt>--name-status
</tt> has been
624 given, do not munge pathnames and use NULs as output field terminators.
626 <div class=
"paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
627 and backslash characters replaced with
<tt>\t
</tt>,
<tt>\n
</tt>,
<tt>\
"</tt>, and <tt>\\</tt>,
628 respectively, and the pathname will be enclosed in double quotes if
629 any of those replacements occurred.</p></div>
636 Show only names of changed files.
644 Show only names and status of changed files. See the description
645 of the <tt>--diff-filter</tt> option on what the status letters mean.
649 --submodule[=<format>]
653 Chose the output format for submodule differences. <format> can be one of
654 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
655 is used when this option is not given. <em>log</em> is the default value for this
656 option and lists the commits in that commit range like the <em>summary</em>
657 option of <a href="git-submodule.html
">git-submodule(1)</a> does.
661 --color[=<when>]
666 The value must be <tt>always</tt> (the default for <tt><when></tt>), <tt>never</tt>, or <tt>auto</tt>.
667 The default value is <tt>never</tt>.
675 Turn off colored diff.
676 It is the same as <tt>--color=never</tt>.
680 --word-diff[=<mode>]
684 Show a word diff, using the <mode> to delimit changed words.
685 By default, words are delimited by whitespace; see
686 <tt>--word-diff-regex</tt> below. The <mode> defaults to <em>plain</em>, and
689 <div class="dlist
"><dl>
695 Highlight changed words using only colors. Implies <tt>--color</tt>.
703 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
704 attempts to escape the delimiters if they appear in the input,
705 so the output may be ambiguous.
713 Use a special line-based format intended for script
714 consumption. Added/removed/unchanged runs are printed in the
715 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
716 character at the beginning of the line and extending to the
717 end of the line. Newlines in the input are represented by a
718 tilde <tt>~</tt> on a line of its own.
726 Disable word diff again.
730 <div class="paragraph
"><p>Note that despite the name of the first mode, color is used to
731 highlight the changed parts in all modes if enabled.</p></div>
734 --word-diff-regex=<regex>
738 Use <regex> to decide what a word is, instead of considering
739 runs of non-whitespace to be a word. Also implies
740 <tt>--word-diff</tt> unless it was already enabled.
742 <div class="paragraph
"><p>Every non-overlapping match of the
743 <regex> is considered a word. Anything between these matches is
744 considered whitespace and ignored(!) for the purposes of finding
745 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
746 expression to make sure that it matches all non-whitespace characters.
747 A match that contains a newline is silently truncated(!) at the
749 <div class="paragraph
"><p>The regex can also be set via a diff driver or configuration option, see
750 <a href="gitattributes.html
">gitattributes(1)</a> or <a href="git-config.html
">git-config(1)</a>. Giving it explicitly
751 overrides any diff driver or configuration setting. Diff drivers
752 override configuration settings.</p></div>
755 --color-words[=<regex>]
759 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
760 specified) <tt>--word-diff-regex=<regex></tt>.
768 Turn off rename detection, even when the configuration
769 file gives the default to do so.
777 Warn if changes introduce whitespace errors. What are
778 considered whitespace errors is controlled by <tt>core.whitespace</tt>
779 configuration. By default, trailing whitespaces (including
780 lines that solely consist of whitespaces) and a space character
781 that is immediately followed by a tab character inside the
782 initial indent of the line are considered whitespace errors.
783 Exits with non-zero status if problems are found. Not compatible
792 Instead of the first handful of characters, show the full
793 pre- and post-image blob object names on the "index
"
794 line when generating patch format output.
802 In addition to <tt>--full-index</tt>, output a binary diff that
803 can be applied with <tt>git-apply</tt>.
811 Instead of showing the full 40-byte hexadecimal object
812 name in diff-raw format output and diff-tree header
813 lines, show only a partial prefix. This is
814 independent of the <tt>--full-index</tt> option above, which controls
815 the diff-patch output format. Non default number of
816 digits can be specified with <tt>--abbrev=<n></tt>.
820 -B[<n>][/<m>]
823 --break-rewrites[=[<n>][/<m>]]
827 Break complete rewrite changes into pairs of delete and
828 create. This serves two purposes:
830 <div class="paragraph
"><p>It affects the way a change that amounts to a total rewrite of a file
831 not as a series of deletion and insertion mixed together with a very
832 few lines that happen to match textually as the context, but as a
833 single deletion of everything old followed by a single insertion of
834 everything new, and the number <tt>m</tt> controls this aspect of the -B
835 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
836 original should remain in the result for git to consider it a total
837 rewrite (i.e. otherwise the resulting patch will be a series of
838 deletion and insertion mixed together with context lines).</p></div>
839 <div class="paragraph
"><p>When used with -M, a totally-rewritten file is also considered as the
840 source of a rename (usually -M only considers a file that disappeared
841 as the source of a rename), and the number <tt>n</tt> controls this aspect of
842 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
843 addition and deletion compared to 20% or more of the file’s size are
844 eligible for being picked up as a possible source of a rename to
845 another file.</p></div>
851 --find-renames[=<n>]
856 If <tt>n</tt> is specified, it is a threshold on the similarity
857 index (i.e. amount of addition/deletions compared to the
858 file’s size). For example, <tt>-M90%</tt> means git should consider a
859 delete/add pair to be a rename if more than 90% of the file
860 hasn’t changed.
867 --find-copies[=<n>]
871 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
872 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M<n></tt>.
880 For performance reasons, by default, <tt>-C</tt> option finds copies only
881 if the original file of the copy was modified in the same
882 changeset. This flag makes the command
883 inspect unmodified files as candidates for the source of
884 copy. This is a very expensive operation for large
885 projects, so use it with caution. Giving more than one
886 <tt>-C</tt> option has the same effect.
893 --irreversible-delete
897 Omit the preimage for deletes, i.e. print only the header but not
898 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
899 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
900 solely for people who want to just concentrate on reviewing the
901 text after the change. In addition, the output obviously lack
902 enough information to apply such a patch in reverse, even manually,
903 hence the name of the option.
905 <div class="paragraph
"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
906 of a delete/create pair.</p></div>
913 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
914 is the number of potential rename/copy targets. This
915 option prevents rename/copy detection from running if
916 the number of rename/copy targets exceeds the specified
921 --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]]
925 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
926 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
927 type (i.e. regular file, symlink, submodule, …) changed (<tt>T</tt>),
928 are Unmerged (<tt>U</tt>), are
929 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
930 Any combination of the filter characters (including none) can be used.
931 When <tt>*</tt> (All-or-none) is added to the combination, all
932 paths are selected if there is any file that matches
933 other criteria in the comparison; if there is no file
934 that matches other criteria, nothing is selected.
942 Look for differences that introduce or remove an instance of
943 <string>. Note that this is different than the string simply
944 appearing in diff output; see the <em>pickaxe</em> entry in
945 <a href="gitdiffcore.html
">gitdiffcore(7)</a> for more details.
953 Look for differences whose added or removed line matches
954 the given <regex>.
962 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
963 changeset, not just the files that contain the change
972 Make the <string> not a plain string but an extended POSIX
981 Output the patch in the order specified in the
982 <orderfile>, which has one shell glob pattern per line.
990 Swap two inputs; that is, show differences from index or
991 on-disk file to tree contents.
995 --relative[=<path>]
999 When run from a subdirectory of the project, it can be
1000 told to exclude changes outside the directory and show
1001 pathnames relative to it with this option. When you are
1002 not in a subdirectory (e.g. in a bare repository), you
1003 can name which subdirectory to make the output relative
1004 to by giving a <path> as an argument.
1007 <dt class="hdlist1
">
1010 <dt class="hdlist1
">
1015 Treat all files as text.
1018 <dt class="hdlist1
">
1019 --ignore-space-at-eol
1023 Ignore changes in whitespace at EOL.
1026 <dt class="hdlist1
">
1029 <dt class="hdlist1
">
1030 --ignore-space-change
1034 Ignore changes in amount of whitespace. This ignores whitespace
1035 at line end, and considers all other sequences of one or
1036 more whitespace characters to be equivalent.
1039 <dt class="hdlist1
">
1042 <dt class="hdlist1
">
1047 Ignore whitespace when comparing lines. This ignores
1048 differences even if one line has whitespace where the other
1052 <dt class="hdlist1
">
1053 --inter-hunk-context=<lines>
1057 Show the context between diff hunks, up to the specified number
1058 of lines, thereby fusing hunks that are close to each other.
1061 <dt class="hdlist1
">
1066 Make the program exit with codes similar to diff(1).
1067 That is, it exits with 1 if there were differences and
1068 0 means no differences.
1071 <dt class="hdlist1
">
1076 Disable all output of the program. Implies <tt>--exit-code</tt>.
1079 <dt class="hdlist1
">
1084 Allow an external diff helper to be executed. If you set an
1085 external diff driver with <a href="gitattributes.html
">gitattributes(5)</a>, you need
1086 to use this option with <a href="git-log.html
">git-log(1)</a> and friends.
1089 <dt class="hdlist1
">
1094 Disallow external diff drivers.
1097 <dt class="hdlist1
">
1100 <dt class="hdlist1
">
1105 Allow (or disallow) external text conversion filters to be run
1106 when comparing binary files. See <a href="gitattributes.html
">gitattributes(5)</a> for
1107 details. Because textconv filters are typically a one-way
1108 conversion, the resulting diff is suitable for human
1109 consumption, but cannot be applied. For this reason, textconv
1110 filters are enabled by default only for <a href="git-diff.html
">git-diff(1)</a> and
1111 <a href="git-log.html
">git-log(1)</a>, but not for <a href="git-format-patch.html
">git-format-patch(1)</a> or
1112 diff plumbing commands.
1115 <dt class="hdlist1
">
1116 --ignore-submodules[=<when>]
1120 Ignore changes to submodules in the diff generation. <when> can be
1121 either "none
", "untracked
", "dirty
" or "all
", which is the default
1122 Using "none
" will consider the submodule modified when it either contains
1123 untracked or modified files or its HEAD differs from the commit recorded
1124 in the superproject and can be used to override any settings of the
1125 <em>ignore</em> option in <a href="git-config.html
">git-config(1)</a> or <a href="gitmodules.html
">gitmodules(5)</a>. When
1126 "untracked
" is used submodules are not considered dirty when they only
1127 contain untracked content (but they are still scanned for modified
1128 content). Using "dirty
" ignores all changes to the work tree of submodules,
1129 only changes to the commits stored in the superproject are shown (this was
1130 the behavior until 1.7.0). Using "all
" hides all changes to submodules.
1133 <dt class="hdlist1
">
1134 --src-prefix=<prefix>
1138 Show the given source prefix instead of "a/
".
1141 <dt class="hdlist1
">
1142 --dst-prefix=<prefix>
1146 Show the given destination prefix instead of "b/
".
1149 <dt class="hdlist1
">
1154 Do not show any source or destination prefix.
1158 <div class="paragraph
"><p>For more detailed explanation on these common options, see also
1159 <a href="gitdiffcore.html
">gitdiffcore(7)</a>.</p></div>
1160 <div class="dlist
"><dl>
1161 <dt class="hdlist1
">
1166 The id of a tree object to diff against.
1169 <dt class="hdlist1
">
1174 do not consider the on-disk file at all
1177 <dt class="hdlist1
">
1182 By default, files recorded in the index but not checked
1183 out are reported as deleted. This flag makes
1184 <em>git diff-index</em> say that all non-checked-out files are up
1190 <h2 id="_raw_output_format
">Raw output format</h2>
1191 <div class="sectionbody
">
1192 <div class="paragraph
"><p>The raw output format from "git-diff-index
", "git-diff-tree
",
1193 "git-diff-files
" and "git diff --raw
" are very similar.</p></div>
1194 <div class="paragraph
"><p>These commands all compare two sets of things; what is
1195 compared differs:</p></div>
1196 <div class="dlist
"><dl>
1197 <dt class="hdlist1
">
1198 git-diff-index <tree-ish>
1202 compares the <tree-ish> and the files on the filesystem.
1205 <dt class="hdlist1
">
1206 git-diff-index --cached <tree-ish>
1210 compares the <tree-ish> and the index.
1213 <dt class="hdlist1
">
1214 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…]
1218 compares the trees named by the two arguments.
1221 <dt class="hdlist1
">
1222 git-diff-files [<pattern>…]
1226 compares the index and the files on the filesystem.
1230 <div class="paragraph
"><p>The "git-diff-tree
" command begins its output by printing the hash of
1231 what is being compared. After that, all the commands print one output
1232 line per changed file.</p></div>
1233 <div class="paragraph
"><p>An output line is formatted this way:</p></div>
1234 <div class="listingblock
">
1235 <div class="content
">
1236 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1237 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1238 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1239 create :000000 100644 0000000... 1234567... A file4
1240 delete :100644 000000 1234567... 0000000... D file5
1241 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1243 <div class="paragraph
"><p>That is, from the left to the right:</p></div>
1244 <div class="olist arabic
"><ol class="arabic
">
1252 mode for "src
"; 000000 if creation or unmerged.
1262 mode for "dst
"; 000000 if deletion or unmerged.
1272 sha1 for "src
"; 0{40} if creation or unmerged.
1282 sha1 for "dst
"; 0{40} if creation, unmerged or "look at work tree
".
1292 status, followed by optional "score
" number.
1297 a tab or a NUL when <em>-z</em> option is used.
1307 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1312 path for "dst
"; only exists for C or R.
1317 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1321 <div class="paragraph
"><p>Possible status letters are:</p></div>
1322 <div class="ulist
"><ul>
1325 A: addition of a file
1330 C: copy of a file into a new one
1335 D: deletion of a file
1340 M: modification of the contents or mode of a file
1345 R: renaming of a file
1350 T: change in the type of the file
1355 U: file is unmerged (you must complete the merge before it can
1361 X: "unknown
" change type (most probably a bug, please report it)
1365 <div class="paragraph
"><p>Status letters C and R are always followed by a score (denoting the
1366 percentage of similarity between the source and target of the move or
1367 copy), and are the only ones to be so.</p></div>
1368 <div class="paragraph
"><p><sha1> is shown as all 0’s if a file is new on the filesystem
1369 and it is out of sync with the index.</p></div>
1370 <div class="paragraph
"><p>Example:</p></div>
1371 <div class="listingblock
">
1372 <div class="content
">
1373 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1375 <div class="paragraph
"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1376 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1377 respectively.</p></div>
1379 <h2 id="_diff_format_for_merges
">diff format for merges</h2>
1380 <div class="sectionbody
">
1381 <div class="paragraph
"><p>"git-diff-tree
", "git-diff-files
" and "git-diff --raw
"
1382 can take <em>-c</em> or <em>--cc</em> option
1383 to generate diff output also for merge commits. The output differs
1384 from the format described above in the following way:</p></div>
1385 <div class="olist arabic
"><ol class="arabic
">
1388 there is a colon for each parent
1393 there are more "src
" modes and "src
" sha1
1398 status is concatenated status characters for each parent
1403 no optional "score
" number
1408 single path, only for "dst
"
1412 <div class="paragraph
"><p>Example:</p></div>
1413 <div class="listingblock
">
1414 <div class="content
">
1415 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1417 <div class="paragraph
"><p>Note that <em>combined diff</em> lists only files which were modified from
1418 all parents.</p></div>
1420 <h2 id="_generating_patches_with_p
">Generating patches with -p</h2>
1421 <div class="sectionbody
">
1422 <div class="paragraph
"><p>When "git-diff-index
", "git-diff-tree
", or "git-diff-files
" are run
1423 with a <em>-p</em> option, "git diff
" without the <em>--raw</em> option, or
1424 "git log
" with the "-p
" option, they
1425 do not produce the output described above; instead they produce a
1426 patch file. You can customize the creation of such patches via the
1427 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1428 <div class="paragraph
"><p>What the -p option produces is slightly different from the traditional
1429 diff format:</p></div>
1430 <div class="olist arabic
"><ol class="arabic
">
1433 It is preceded with a "git diff
" header that looks like this:
1435 <div class="literalblock
">
1436 <div class="content
">
1437 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1439 <div class="paragraph
"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1440 involved. Especially, even for a creation or a deletion,
1441 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1442 <div class="paragraph
"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1443 name of the source file of the rename/copy and the name of
1444 the file that rename/copy produces, respectively.</p></div>
1448 It is followed by one or more extended header lines:
1450 <div class="literalblock
">
1451 <div class="content
">
1452 <pre><tt>old mode <mode>
1453 new mode <mode>
1454 deleted file mode <mode>
1455 new file mode <mode>
1456 copy from <path>
1457 copy to <path>
1458 rename from <path>
1459 rename to <path>
1460 similarity index <number>
1461 dissimilarity index <number>
1462 index <hash>..<hash> <mode></tt></pre>
1464 <div class="paragraph
"><p>File modes are printed as 6-digit octal numbers including the file type
1465 and file permission bits.</p></div>
1466 <div class="paragraph
"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1467 <div class="paragraph
"><p>The similarity index is the percentage of unchanged lines, and
1468 the dissimilarity index is the percentage of changed lines. It
1469 is a rounded down integer, followed by a percent sign. The
1470 similarity index value of 100% is thus reserved for two equal
1471 files, while 100% dissimilarity means that no line from the old
1472 file made it into the new one.</p></div>
1473 <div class="paragraph
"><p>The index line includes the SHA-1 checksum before and after the change.
1474 The <mode> is included if the file mode does not change; otherwise,
1475 separate lines indicate the old and the new mode.</p></div>
1479 TAB, LF, double quote and backslash characters in pathnames
1480 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and
<tt>\\
</tt>, respectively.
1481 If there is need for such substitution then the whole
1482 pathname is put in double quotes.
1487 All the
<tt>file1
</tt> files in the output refer to files before the
1488 commit, and all the
<tt>file2
</tt> files refer to files after the commit.
1489 It is incorrect to apply each change to each file sequentially. For
1490 example, this patch will swap a and b:
1492 <div class=
"literalblock">
1493 <div class=
"content">
1494 <pre><tt>diff --git a/a b/b
1499 rename to a
</tt></pre>
1504 <h2 id=
"_combined_diff_format">combined diff format
</h2>
1505 <div class=
"sectionbody">
1506 <div class=
"paragraph"><p>Any diff-generating command can take the
‘-c` or
<tt>--cc
</tt> option to
1507 produce a
<em>combined diff
</em> when showing a merge. This is the default
1508 format when showing merges with
<a href=
"git-diff.html">git-diff(
1)
</a> or
1509 <a href=
"git-show.html">git-show(
1)
</a>. Note also that you can give the `-m
’ option to any
1510 of these commands to force generation of diffs with individual parents
1511 of a merge.
</p></div>
1512 <div class=
"paragraph"><p>A
<em>combined diff
</em> format looks like this:
</p></div>
1513 <div class=
"listingblock">
1514 <div class=
"content">
1515 <pre><tt>diff --combined describe.c
1516 index fabadb8,cc95eb0.
.4866510
1519 @@@ -
98,
20 -
98,
12 +
98,
20 @@@
1520 return (a_date
> b_date) ? -
1 : (a_date == b_date) ?
0 :
1;
1523 - static void describe(char *arg)
1524 -static void describe(struct commit *cmit, int last_one)
1525 ++static void describe(char *arg, int last_one)
1527 + unsigned char sha1[
20];
1528 + struct commit *cmit;
1529 struct commit_list *list;
1530 static int initialized =
0;
1531 struct commit_name *n;
1533 + if (get_sha1(arg, sha1)
< 0)
1534 + usage(describe_usage);
1535 + cmit = lookup_commit_reference(sha1);
1537 + usage(describe_usage);
1541 for_each_ref(get_name);
</tt></pre>
1543 <div class=
"olist arabic"><ol class=
"arabic">
1546 It is preceded with a
"git diff" header, that looks like
1547 this (when
<em>-c
</em> option is used):
1549 <div class=
"literalblock">
1550 <div class=
"content">
1551 <pre><tt>diff --combined file
</tt></pre>
1553 <div class=
"paragraph"><p>or like this (when
<em>--cc
</em> option is used):
</p></div>
1554 <div class=
"literalblock">
1555 <div class=
"content">
1556 <pre><tt>diff --cc file
</tt></pre>
1561 It is followed by one or more extended header lines
1562 (this example shows a merge with two parents):
1564 <div class=
"literalblock">
1565 <div class=
"content">
1566 <pre><tt>index
<hash
>,
<hash
>..
<hash
>
1567 mode
<mode
>,
<mode
>..
<mode
>
1568 new file mode
<mode
>
1569 deleted file mode
<mode
>,
<mode
></tt></pre>
1571 <div class=
"paragraph"><p>The
<tt>mode
<mode
>,
<mode
>..
<mode
></tt> line appears only if at least one of
1572 the
<mode
> is different from the rest. Extended headers with
1573 information about detected contents movement (renames and
1574 copying detection) are designed to work with diff of two
1575 <tree-ish
> and are not used by combined diff format.
</p></div>
1579 It is followed by two-line from-file/to-file header
1581 <div class=
"literalblock">
1582 <div class=
"content">
1584 +++ b/file
</tt></pre>
1586 <div class=
"paragraph"><p>Similar to two-line header for traditional
<em>unified
</em> diff
1587 format,
<tt>/dev/null
</tt> is used to signal created or deleted
1592 Chunk header format is modified to prevent people from
1593 accidentally feeding it to
<tt>patch -p1
</tt>. Combined diff format
1594 was created for review of merge commit changes, and was not
1595 meant for apply. The change is similar to the change in the
1596 extended
<em>index
</em> header:
1598 <div class=
"literalblock">
1599 <div class=
"content">
1600 <pre><tt>@@@
<from-file-range
> <from-file-range
> <to-file-range
> @@@
</tt></pre>
1602 <div class=
"paragraph"><p>There are (number of parents +
1)
<tt>@
</tt> characters in the chunk
1603 header for combined diff format.
</p></div>
1606 <div class=
"paragraph"><p>Unlike the traditional
<em>unified
</em> diff format, which shows two
1607 files A and B with a single column that has
<tt>-
</tt> (minus
 — appears in A but removed in B),
<tt>+
</tt> (plus
 — missing in A but
1608 added to B), or
<tt>" "</tt> (space
 — unchanged) prefix, this format
1609 compares two or more files file1, file2,
… with one file X, and
1610 shows how X differs from each of fileN. One column for each of
1611 fileN is prepended to the output line to note how X
’s line is
1612 different from it.
</p></div>
1613 <div class=
"paragraph"><p>A
<tt>-
</tt> character in the column N means that the line appears in
1614 fileN but it does not appear in the result. A
<tt>+
</tt> character
1615 in the column N means that the line appears in the result,
1616 and fileN does not have that line (in other words, the line was
1617 added, from the point of view of that parent).
</p></div>
1618 <div class=
"paragraph"><p>In the above example output, the function signature was changed
1619 from both files (hence two
<tt>-
</tt> removals from both file1 and
1620 file2, plus
<tt>++
</tt> to mean one line that was added does not appear
1621 in either file1 nor file2). Also eight other lines are the same
1622 from file1 but do not appear in file2 (hence prefixed with
<tt>+</tt>).
</p></div>
1623 <div class=
"paragraph"><p>When shown by
<tt>git diff-tree -c
</tt>, it compares the parents of a
1624 merge commit with the merge result (i.e. file1..fileN are the
1625 parents). When shown by
<tt>git diff-files -c
</tt>, it compares the
1626 two unresolved merge parents with the working tree file
1627 (i.e. file1 is stage
2 aka
"our version", file2 is stage
3 aka
1628 "their version").
</p></div>
1630 <h2 id=
"_other_diff_formats">other diff formats
</h2>
1631 <div class=
"sectionbody">
1632 <div class=
"paragraph"><p>The
<tt>--summary
</tt> option describes newly added, deleted, renamed and
1633 copied files. The
<tt>--stat
</tt> option adds diffstat(
1) graph to the
1634 output. These options can be combined with other options, such as
1635 <tt>-p
</tt>, and are meant for human consumption.
</p></div>
1636 <div class=
"paragraph"><p>When showing a change that involves a rename or a copy,
<tt>--stat
</tt> output
1637 formats the pathnames compactly by combining common prefix and suffix of
1638 the pathnames. For example, a change that moves
<tt>arch/i386/Makefile
</tt> to
1639 <tt>arch/x86/Makefile
</tt> while modifying
4 lines will be shown like this:
</p></div>
1640 <div class=
"listingblock">
1641 <div class=
"content">
1642 <pre><tt>arch/{i386 =
> x86}/Makefile |
4 +--
</tt></pre>
1644 <div class=
"paragraph"><p>The
<tt>--numstat
</tt> option gives the diffstat(
1) information but is designed
1645 for easier machine consumption. An entry in
<tt>--numstat
</tt> output looks
1646 like this:
</p></div>
1647 <div class=
"listingblock">
1648 <div class=
"content">
1650 3 1 arch/{i386 =
> x86}/Makefile
</tt></pre>
1652 <div class=
"paragraph"><p>That is, from left to right:
</p></div>
1653 <div class=
"olist arabic"><ol class=
"arabic">
1656 the number of added lines;
1666 the number of deleted lines;
1676 pathname (possibly with rename/copy information);
1685 <div class=
"paragraph"><p>When
<tt>-z
</tt> output option is in effect, the output is formatted this way:
</p></div>
1686 <div class=
"listingblock">
1687 <div class=
"content">
1688 <pre><tt>1 2 README NUL
1689 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
</tt></pre>
1691 <div class=
"paragraph"><p>That is:
</p></div>
1692 <div class=
"olist arabic"><ol class=
"arabic">
1695 the number of added lines;
1705 the number of deleted lines;
1715 a NUL (only exists if renamed/copied);
1720 pathname in preimage;
1725 a NUL (only exists if renamed/copied);
1730 pathname in postimage (only exists if renamed/copied);
1739 <div class=
"paragraph"><p>The extra
<tt>NUL
</tt> before the preimage path in renamed case is to allow
1740 scripts that read the output to tell if the current record being read is
1741 a single-path record or a rename/copy record without reading ahead.
1742 After reading added and deleted lines, reading up to
<tt>NUL
</tt> would yield
1743 the pathname, but if that is
<tt>NUL
</tt>, the record will show two paths.
</p></div>
1745 <h2 id=
"_operating_modes">Operating Modes
</h2>
1746 <div class=
"sectionbody">
1747 <div class=
"paragraph"><p>You can choose whether you want to trust the index file entirely
1748 (using the
<em>--cached
</em> flag) or ask the diff logic to show any files
1749 that don
’t match the stat state as being
"tentatively changed". Both
1750 of these operations are very useful indeed.
</p></div>
1752 <h2 id=
"_cached_mode">Cached Mode
</h2>
1753 <div class=
"sectionbody">
1754 <div class=
"paragraph"><p>If
<em>--cached
</em> is specified, it allows you to ask:
</p></div>
1755 <div class=
"literalblock">
1756 <div class=
"content">
1757 <pre><tt>show me the differences between HEAD and the current index
1758 contents (the ones I'd write using 'git write-tree')
</tt></pre>
1760 <div class=
"paragraph"><p>For example, let
’s say that you have worked on your working directory, updated
1761 some files in the index and are ready to commit. You want to see exactly
1762 <strong>what
</strong> you are going to commit, without having to write a new tree
1763 object and compare it that way, and to do that, you just do
</p></div>
1764 <div class=
"literalblock">
1765 <div class=
"content">
1766 <pre><tt>git diff-index --cached HEAD
</tt></pre>
1768 <div class=
"paragraph"><p>Example: let
’s say I had renamed
<tt>commit.c
</tt> to
<tt>git-commit.c
</tt>, and I had
1769 done an
<tt>update-index
</tt> to make that effective in the index file.
1770 <tt>git diff-files
</tt> wouldn
’t show anything at all, since the index file
1771 matches my working directory. But doing a
<em>git diff-index
</em> does:
</p></div>
1772 <div class=
"literalblock">
1773 <div class=
"content">
1774 <pre><tt>torvalds@ppc970:~/git
> git diff-index --cached HEAD
1775 -
100644 blob
4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
1776 +
100644 blob
4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c
</tt></pre>
1778 <div class=
"paragraph"><p>You can see easily that the above is a rename.
</p></div>
1779 <div class=
"paragraph"><p>In fact,
<tt>git diff-index --cached
</tt> <strong>should
</strong> always be entirely equivalent to
1780 actually doing a
<em>git write-tree
</em> and comparing that. Except this one is much
1781 nicer for the case where you just want to check where you are.
</p></div>
1782 <div class=
"paragraph"><p>So doing a
<tt>git diff-index --cached
</tt> is basically very useful when you are
1783 asking yourself
"what have I already marked for being committed, and
1784 what’s the difference to a previous tree".
</p></div>
1786 <h2 id=
"_non_cached_mode">Non-cached Mode
</h2>
1787 <div class=
"sectionbody">
1788 <div class=
"paragraph"><p>The
"non-cached" mode takes a different approach, and is potentially
1789 the more useful of the two in that what it does can
’t be emulated with
1790 a
<em>git write-tree
</em> +
<em>git diff-tree
</em>. Thus that
’s the default mode.
1791 The non-cached version asks the question:
</p></div>
1792 <div class=
"literalblock">
1793 <div class=
"content">
1794 <pre><tt>show me the differences between HEAD and the currently checked out
1795 tree - index contents _and_ files that aren't up-to-date
</tt></pre>
1797 <div class=
"paragraph"><p>which is obviously a very useful question too, since that tells you what
1798 you
<strong>could
</strong> commit. Again, the output matches the
<em>git diff-tree -r
</em>
1799 output to a tee, but with a twist.
</p></div>
1800 <div class=
"paragraph"><p>The twist is that if some file doesn
’t match the index, we don
’t have
1801 a backing store thing for it, and we use the magic
"all-zero" sha1 to
1802 show that. So let
’s say that you have edited
<tt>kernel/sched.c
</tt>, but
1803 have not actually done a
<em>git update-index
</em> on it yet - there is no
1804 "object" associated with the new state, and you get:
</p></div>
1805 <div class=
"literalblock">
1806 <div class=
"content">
1807 <pre><tt>torvalds@ppc970:~/v2.6/linux
> git diff-index --abbrev HEAD
1808 :
100644 100664 7476bb...
000000... kernel/sched.c
</tt></pre>
1810 <div class=
"paragraph"><p>i.e., it shows that the tree has changed, and that
<tt>kernel/sched.c
</tt> has is
1811 not up-to-date and may contain new stuff. The all-zero sha1 means that to
1812 get the real diff, you need to look at the object in the working directory
1813 directly rather than do an object-to-object diff.
</p></div>
1814 <div class=
"admonitionblock">
1817 <div class=
"title">Note
</div>
1819 <td class=
"content">As with other commands of this type,
<em>git diff-index
</em> does not
1820 actually look at the contents of the file at all. So maybe
1821 <tt>kernel/sched.c
</tt> hasn
’t actually changed, and it
’s just that you
1822 touched it. In either case, it
’s a note that you need to
1823 <em>git update-index
</em> it to make the index be in sync.
</td>
1826 <div class=
"admonitionblock">
1829 <div class=
"title">Note
</div>
1831 <td class=
"content">You can have a mixture of files show up as
"has been updated"
1832 and
"is still dirty in the working directory" together. You can always
1833 tell which file is in which state, since the
"has been updated" ones
1834 show a valid sha1, and the
"not in sync with the index" ones will
1835 always have the special all-zero sha1.
</td>
1839 <h2 id=
"_git">GIT
</h2>
1840 <div class=
"sectionbody">
1841 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1844 <div id=
"footer-text">
1845 Last updated
2011-
07-
23 00:
49:
30 UTC