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-files(
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-files(
1) Manual Page
409 <div class=
"sectionbody">
411 Compares files in the working tree and the index
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"paragraph"><p><em>git diff-files
</em> [-q] [-
0|-
1|-
2|-
3|-c|--cc] [
<common diff options
>] [
<path
>…]
</p></div>
419 <h2 id=
"_description">DESCRIPTION
</h2>
420 <div class=
"sectionbody">
421 <div class=
"paragraph"><p>Compares the files in the working tree and the index. When paths
422 are specified, compares only those named paths. Otherwise all
423 entries in the index are compared. The output format is the
424 same as for
<em>git diff-index
</em> and
<em>git diff-tree
</em>.
</p></div>
426 <h2 id=
"_options">OPTIONS
</h2>
427 <div class=
"sectionbody">
428 <div class=
"dlist"><dl>
440 Generate patch (see section on generating patches).
452 Generate diffs with
<n
> lines of context instead of
462 Generate the raw format.
471 Synonym for
<tt>-p --raw
</tt>.
479 Generate a diff using the
"patience diff" algorithm.
483 --stat[=
<width
>[,
<name-width
>]]
487 Generate a diffstat. You can override the default
488 output width for
80-column terminal by
<tt>--stat=
<width
></tt>.
489 The width of the filename part can be controlled by
490 giving another width to it separated by a comma.
498 Similar to
<tt>--stat
</tt>, but shows number of added and
499 deleted lines in decimal notation and pathname without
500 abbreviation, to make it more machine friendly. For
501 binary files, outputs two
<tt>-
</tt> instead of saying
510 Output only the last line of the
<tt>--stat
</tt> format containing total
511 number of modified files, as well as number of added and deleted
516 --dirstat[=
<limit
>]
520 Output the distribution of relative amount of changes (number of lines added or
521 removed) for each sub-directory. Directories with changes below
522 a cut-off percent (
3% by default) are not shown. The cut-off percent
523 can be set with
<tt>--dirstat=
<limit
></tt>. Changes in a child directory are not
524 counted for the parent directory, unless
<tt>--cumulative
</tt> is used.
528 --dirstat-by-file[=
<limit
>]
532 Same as
<tt>--dirstat
</tt>, but counts changed files instead of lines.
540 Output a condensed summary of extended header information
541 such as creations, renames and mode changes.
549 Synonym for
<tt>-p --stat
</tt>.
557 When
<tt>--raw
</tt>,
<tt>--numstat
</tt>,
<tt>--name-only
</tt> or
<tt>--name-status
</tt> has been
558 given, do not munge pathnames and use NULs as output field terminators.
560 <div class=
"paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
561 and backslash characters replaced with
<tt>\t
</tt>,
<tt>\n
</tt>,
<tt>\
"</tt>, and <tt>\\</tt>,
562 respectively, and the pathname will be enclosed in double quotes if
563 any of those replacements occurred.</p></div>
570 Show only names of changed files.
578 Show only names and status of changed files. See the description
579 of the <tt>--diff-filter</tt> option on what the status letters mean.
583 --submodule[=<format>]
587 Chose the output format for submodule differences. <format> can be one of
588 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
589 is used when this option is not given. <em>log</em> is the default value for this
590 option and lists the commits in that commit range like the <em>summary</em>
591 option of <a href="git-submodule.html
">git-submodule(1)</a> does.
595 --color[=<when>]
600 The value must be always (the default), never, or auto.
608 Turn off colored diff, even when the configuration file
609 gives the default to color output.
610 Same as <tt>--color=never</tt>.
614 --word-diff[=<mode>]
618 Show a word diff, using the <mode> to delimit changed words.
619 By default, words are delimited by whitespace; see
620 <tt>--word-diff-regex</tt> below. The <mode> defaults to <em>plain</em>, and
623 <div class="dlist
"><dl>
629 Highlight changed words using only colors. Implies <tt>--color</tt>.
637 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
638 attempts to escape the delimiters if they appear in the input,
639 so the output may be ambiguous.
647 Use a special line-based format intended for script
648 consumption. Added/removed/unchanged runs are printed in the
649 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
650 character at the beginning of the line and extending to the
651 end of the line. Newlines in the input are represented by a
652 tilde <tt>~</tt> on a line of its own.
660 Disable word diff again.
664 <div class="paragraph
"><p>Note that despite the name of the first mode, color is used to
665 highlight the changed parts in all modes if enabled.</p></div>
668 --word-diff-regex=<regex>
672 Use <regex> to decide what a word is, instead of considering
673 runs of non-whitespace to be a word. Also implies
674 <tt>--word-diff</tt> unless it was already enabled.
676 <div class="paragraph
"><p>Every non-overlapping match of the
677 <regex> is considered a word. Anything between these matches is
678 considered whitespace and ignored(!) for the purposes of finding
679 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
680 expression to make sure that it matches all non-whitespace characters.
681 A match that contains a newline is silently truncated(!) at the
683 <div class="paragraph
"><p>The regex can also be set via a diff driver or configuration option, see
684 <a href="gitattributes.html
">gitattributes(1)</a> or <a href="git-config.html
">git-config(1)</a>. Giving it explicitly
685 overrides any diff driver or configuration setting. Diff drivers
686 override configuration settings.</p></div>
689 --color-words[=<regex>]
693 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
694 specified) <tt>--word-diff-regex=<regex></tt>.
702 Turn off rename detection, even when the configuration
703 file gives the default to do so.
711 Warn if changes introduce trailing whitespace
712 or an indent that uses a space before a tab. Exits with
713 non-zero status if problems are found. Not compatible with
722 Instead of the first handful of characters, show the full
723 pre- and post-image blob object names on the "index
"
724 line when generating patch format output.
732 In addition to <tt>--full-index</tt>, output a binary diff that
733 can be applied with <tt>git-apply</tt>.
741 Instead of showing the full 40-byte hexadecimal object
742 name in diff-raw format output and diff-tree header
743 lines, show only a partial prefix. This is
744 independent of the <tt>--full-index</tt> option above, which controls
745 the diff-patch output format. Non default number of
746 digits can be specified with <tt>--abbrev=<n></tt>.
750 -B[<n>][/<m>]
753 --break-rewrites[=[<n>][/<m>]]
757 Break complete rewrite changes into pairs of delete and
758 create. This serves two purposes:
760 <div class="paragraph
"><p>It affects the way a change that amounts to a total rewrite of a file
761 not as a series of deletion and insertion mixed together with a very
762 few lines that happen to match textually as the context, but as a
763 single deletion of everything old followed by a single insertion of
764 everything new, and the number <tt>m</tt> controls this aspect of the -B
765 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
766 original should remain in the result for git to consider it a total
767 rewrite (i.e. otherwise the resulting patch will be a series of
768 deletion and insertion mixed together with context lines).</p></div>
769 <div class="paragraph
"><p>When used with -M, a totally-rewritten file is also considered as the
770 source of a rename (usually -M only considers a file that disappeared
771 as the source of a rename), and the number <tt>n</tt> controls this aspect of
772 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
773 addition and deletion compared to 20% or more of the file’s size are
774 eligible for being picked up as a possible source of a rename to
775 another file.</p></div>
781 --find-renames[=<n>]
786 If <tt>n</tt> is specified, it is a is a threshold on the similarity
787 index (i.e. amount of addition/deletions compared to the
788 file’s size). For example, <tt>-M90%</tt> means git should consider a
789 delete/add pair to be a rename if more than 90% of the file
790 hasn’t changed.
797 --find-copies[=<n>]
801 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
802 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M<n></tt>.
810 For performance reasons, by default, <tt>-C</tt> option finds copies only
811 if the original file of the copy was modified in the same
812 changeset. This flag makes the command
813 inspect unmodified files as candidates for the source of
814 copy. This is a very expensive operation for large
815 projects, so use it with caution. Giving more than one
816 <tt>-C</tt> option has the same effect.
824 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
825 is the number of potential rename/copy targets. This
826 option prevents rename/copy detection from running if
827 the number of rename/copy targets exceeds the specified
832 --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]]
836 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
837 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
838 type (i.e. regular file, symlink, submodule, …) changed (<tt>T</tt>),
839 are Unmerged (<tt>U</tt>), are
840 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
841 Any combination of the filter characters (including none) can be used.
842 When <tt>*</tt> (All-or-none) is added to the combination, all
843 paths are selected if there is any file that matches
844 other criteria in the comparison; if there is no file
845 that matches other criteria, nothing is selected.
853 Look for differences that introduce or remove an instance of
854 <string>. Note that this is different than the string simply
855 appearing in diff output; see the <em>pickaxe</em> entry in
856 <a href="gitdiffcore.html
">gitdiffcore(7)</a> for more details.
864 Look for differences whose added or removed line matches
865 the given <regex>.
873 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
874 changeset, not just the files that contain the change
883 Make the <string> not a plain string but an extended POSIX
892 Output the patch in the order specified in the
893 <orderfile>, which has one shell glob pattern per line.
901 Swap two inputs; that is, show differences from index or
902 on-disk file to tree contents.
906 --relative[=<path>]
910 When run from a subdirectory of the project, it can be
911 told to exclude changes outside the directory and show
912 pathnames relative to it with this option. When you are
913 not in a subdirectory (e.g. in a bare repository), you
914 can name which subdirectory to make the output relative
915 to by giving a <path> as an argument.
926 Treat all files as text.
930 --ignore-space-at-eol
934 Ignore changes in whitespace at EOL.
941 --ignore-space-change
945 Ignore changes in amount of whitespace. This ignores whitespace
946 at line end, and considers all other sequences of one or
947 more whitespace characters to be equivalent.
958 Ignore whitespace when comparing lines. This ignores
959 differences even if one line has whitespace where the other
964 --inter-hunk-context=<lines>
968 Show the context between diff hunks, up to the specified number
969 of lines, thereby fusing hunks that are close to each other.
977 Make the program exit with codes similar to diff(1).
978 That is, it exits with 1 if there were differences and
979 0 means no differences.
987 Disable all output of the program. Implies <tt>--exit-code</tt>.
995 Allow an external diff helper to be executed. If you set an
996 external diff driver with <a href="gitattributes.html
">gitattributes(5)</a>, you need
997 to use this option with <a href="git-log.html
">git-log(1)</a> and friends.
1000 <dt class="hdlist1
">
1005 Disallow external diff drivers.
1008 <dt class="hdlist1
">
1009 --ignore-submodules[=<when>]
1013 Ignore changes to submodules in the diff generation. <when> can be
1014 either "none
", "untracked
", "dirty
" or "all
", which is the default
1015 Using "none
" will consider the submodule modified when it either contains
1016 untracked or modified files or its HEAD differs from the commit recorded
1017 in the superproject and can be used to override any settings of the
1018 <em>ignore</em> option in <a href="git-config.html
">git-config(1)</a> or <a href="gitmodules.html
">gitmodules(5)</a>. When
1019 "untracked
" is used submodules are not considered dirty when they only
1020 contain untracked content (but they are still scanned for modified
1021 content). Using "dirty
" ignores all changes to the work tree of submodules,
1022 only changes to the commits stored in the superproject are shown (this was
1023 the behavior until 1.7.0). Using "all
" hides all changes to submodules.
1026 <dt class="hdlist1
">
1027 --src-prefix=<prefix>
1031 Show the given source prefix instead of "a/
".
1034 <dt class="hdlist1
">
1035 --dst-prefix=<prefix>
1039 Show the given destination prefix instead of "b/
".
1042 <dt class="hdlist1
">
1047 Do not show any source or destination prefix.
1051 <div class="paragraph
"><p>For more detailed explanation on these common options, see also
1052 <a href="gitdiffcore.html
">gitdiffcore(7)</a>.</p></div>
1053 <div class="dlist
"><dl>
1054 <dt class="hdlist1
">
1057 <dt class="hdlist1
">
1060 <dt class="hdlist1
">
1063 <dt class="hdlist1
">
1068 Diff against the "base
" version, "our branch
" or "their
1069 branch
" respectively. With these options, diffs for
1070 merged entries are not shown.
1072 <div class="paragraph
"><p>The default is to diff against our branch (-2) and the
1073 cleanly resolved paths. The option -0 can be given to
1074 omit diff output for unmerged entries and just show "Unmerged
".</p></div>
1076 <dt class="hdlist1
">
1079 <dt class="hdlist1
">
1084 This compares stage 2 (our branch), stage 3 (their
1085 branch) and the working tree file and outputs a combined
1086 diff, similar to the way <em>diff-tree</em> shows a merge
1087 commit with these flags.
1090 <dt class="hdlist1
">
1095 Remain silent even on nonexistent files
1100 <h2 id="_raw_output_format
">Raw output format</h2>
1101 <div class="sectionbody
">
1102 <div class="paragraph
"><p>The raw output format from "git-diff-index
", "git-diff-tree
",
1103 "git-diff-files
" and "git diff --raw
" are very similar.</p></div>
1104 <div class="paragraph
"><p>These commands all compare two sets of things; what is
1105 compared differs:</p></div>
1106 <div class="dlist
"><dl>
1107 <dt class="hdlist1
">
1108 git-diff-index <tree-ish>
1112 compares the <tree-ish> and the files on the filesystem.
1115 <dt class="hdlist1
">
1116 git-diff-index --cached <tree-ish>
1120 compares the <tree-ish> and the index.
1123 <dt class="hdlist1
">
1124 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…]
1128 compares the trees named by the two arguments.
1131 <dt class="hdlist1
">
1132 git-diff-files [<pattern>…]
1136 compares the index and the files on the filesystem.
1140 <div class="paragraph
"><p>The "git-diff-tree
" command begins its output by printing the hash of
1141 what is being compared. After that, all the commands print one output
1142 line per changed file.</p></div>
1143 <div class="paragraph
"><p>An output line is formatted this way:</p></div>
1144 <div class="listingblock
">
1145 <div class="content
">
1146 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1147 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1148 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1149 create :000000 100644 0000000... 1234567... A file4
1150 delete :100644 000000 1234567... 0000000... D file5
1151 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1153 <div class="paragraph
"><p>That is, from the left to the right:</p></div>
1154 <div class="olist arabic
"><ol class="arabic
">
1162 mode for "src
"; 000000 if creation or unmerged.
1172 mode for "dst
"; 000000 if deletion or unmerged.
1182 sha1 for "src
"; 0{40} if creation or unmerged.
1192 sha1 for "dst
"; 0{40} if creation, unmerged or "look at work tree
".
1202 status, followed by optional "score
" number.
1207 a tab or a NUL when <em>-z</em> option is used.
1217 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1222 path for "dst
"; only exists for C or R.
1227 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1231 <div class="paragraph
"><p>Possible status letters are:</p></div>
1232 <div class="ulist
"><ul>
1235 A: addition of a file
1240 C: copy of a file into a new one
1245 D: deletion of a file
1250 M: modification of the contents or mode of a file
1255 R: renaming of a file
1260 T: change in the type of the file
1265 U: file is unmerged (you must complete the merge before it can
1271 X: "unknown
" change type (most probably a bug, please report it)
1275 <div class="paragraph
"><p>Status letters C and R are always followed by a score (denoting the
1276 percentage of similarity between the source and target of the move or
1277 copy), and are the only ones to be so.</p></div>
1278 <div class="paragraph
"><p><sha1> is shown as all 0’s if a file is new on the filesystem
1279 and it is out of sync with the index.</p></div>
1280 <div class="paragraph
"><p>Example:</p></div>
1281 <div class="listingblock
">
1282 <div class="content
">
1283 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1285 <div class="paragraph
"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1286 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1287 respectively.</p></div>
1289 <h2 id="_diff_format_for_merges
">diff format for merges</h2>
1290 <div class="sectionbody
">
1291 <div class="paragraph
"><p>"git-diff-tree
", "git-diff-files
" and "git-diff --raw
"
1292 can take <em>-c</em> or <em>--cc</em> option
1293 to generate diff output also for merge commits. The output differs
1294 from the format described above in the following way:</p></div>
1295 <div class="olist arabic
"><ol class="arabic
">
1298 there is a colon for each parent
1303 there are more "src
" modes and "src
" sha1
1308 status is concatenated status characters for each parent
1313 no optional "score
" number
1318 single path, only for "dst
"
1322 <div class="paragraph
"><p>Example:</p></div>
1323 <div class="listingblock
">
1324 <div class="content
">
1325 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1327 <div class="paragraph
"><p>Note that <em>combined diff</em> lists only files which were modified from
1328 all parents.</p></div>
1330 <h2 id="_generating_patches_with_p
">Generating patches with -p</h2>
1331 <div class="sectionbody
">
1332 <div class="paragraph
"><p>When "git-diff-index
", "git-diff-tree
", or "git-diff-files
" are run
1333 with a <em>-p</em> option, "git diff
" without the <em>--raw</em> option, or
1334 "git log
" with the "-p
" option, they
1335 do not produce the output described above; instead they produce a
1336 patch file. You can customize the creation of such patches via the
1337 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1338 <div class="paragraph
"><p>What the -p option produces is slightly different from the traditional
1339 diff format:</p></div>
1340 <div class="olist arabic
"><ol class="arabic
">
1343 It is preceded with a "git diff
" header that looks like this:
1345 <div class="literalblock
">
1346 <div class="content
">
1347 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1349 <div class="paragraph
"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1350 involved. Especially, even for a creation or a deletion,
1351 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1352 <div class="paragraph
"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1353 name of the source file of the rename/copy and the name of
1354 the file that rename/copy produces, respectively.</p></div>
1358 It is followed by one or more extended header lines:
1360 <div class="literalblock
">
1361 <div class="content
">
1362 <pre><tt>old mode <mode>
1363 new mode <mode>
1364 deleted file mode <mode>
1365 new file mode <mode>
1366 copy from <path>
1367 copy to <path>
1368 rename from <path>
1369 rename to <path>
1370 similarity index <number>
1371 dissimilarity index <number>
1372 index <hash>..<hash> <mode></tt></pre>
1374 <div class="paragraph
"><p>File modes are printed as 6-digit octal numbers including the file type
1375 and file permission bits.</p></div>
1376 <div class="paragraph
"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1377 <div class="paragraph
"><p>The similarity index is the percentage of unchanged lines, and
1378 the dissimilarity index is the percentage of changed lines. It
1379 is a rounded down integer, followed by a percent sign. The
1380 similarity index value of 100% is thus reserved for two equal
1381 files, while 100% dissimilarity means that no line from the old
1382 file made it into the new one.</p></div>
1383 <div class="paragraph
"><p>The index line includes the SHA-1 checksum before and after the change.
1384 The <mode> is included if the file mode does not change; otherwise,
1385 separate lines indicate the old and the new mode.</p></div>
1389 TAB, LF, double quote and backslash characters in pathnames
1390 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and
<tt>\\
</tt>, respectively.
1391 If there is need for such substitution then the whole
1392 pathname is put in double quotes.
1397 All the
<tt>file1
</tt> files in the output refer to files before the
1398 commit, and all the
<tt>file2
</tt> files refer to files after the commit.
1399 It is incorrect to apply each change to each file sequentially. For
1400 example, this patch will swap a and b:
1402 <div class=
"literalblock">
1403 <div class=
"content">
1404 <pre><tt>diff --git a/a b/b
1409 rename to a
</tt></pre>
1414 <h2 id=
"_combined_diff_format">combined diff format
</h2>
1415 <div class=
"sectionbody">
1416 <div class=
"paragraph"><p>"git-diff-tree",
"git-diff-files" and
"git-diff" can take
<em>-c
</em> or
1417 <em>--cc
</em> option to produce
<em>combined diff
</em>. For showing a merge commit
1418 with
"git log -p", this is the default format; you can force showing
1419 full diff with the
<em>-m
</em> option.
1420 A
<em>combined diff
</em> format looks like this:
</p></div>
1421 <div class=
"listingblock">
1422 <div class=
"content">
1423 <pre><tt>diff --combined describe.c
1424 index fabadb8,cc95eb0.
.4866510
1427 @@@ -
98,
20 -
98,
12 +
98,
20 @@@
1428 return (a_date
> b_date) ? -
1 : (a_date == b_date) ?
0 :
1;
1431 - static void describe(char *arg)
1432 -static void describe(struct commit *cmit, int last_one)
1433 ++static void describe(char *arg, int last_one)
1435 + unsigned char sha1[
20];
1436 + struct commit *cmit;
1437 struct commit_list *list;
1438 static int initialized =
0;
1439 struct commit_name *n;
1441 + if (get_sha1(arg, sha1)
< 0)
1442 + usage(describe_usage);
1443 + cmit = lookup_commit_reference(sha1);
1445 + usage(describe_usage);
1449 for_each_ref(get_name);
</tt></pre>
1451 <div class=
"olist arabic"><ol class=
"arabic">
1454 It is preceded with a
"git diff" header, that looks like
1455 this (when
<em>-c
</em> option is used):
1457 <div class=
"literalblock">
1458 <div class=
"content">
1459 <pre><tt>diff --combined file
</tt></pre>
1461 <div class=
"paragraph"><p>or like this (when
<em>--cc
</em> option is used):
</p></div>
1462 <div class=
"literalblock">
1463 <div class=
"content">
1464 <pre><tt>diff --cc file
</tt></pre>
1469 It is followed by one or more extended header lines
1470 (this example shows a merge with two parents):
1472 <div class=
"literalblock">
1473 <div class=
"content">
1474 <pre><tt>index
<hash
>,
<hash
>..
<hash
>
1475 mode
<mode
>,
<mode
>..
<mode
>
1476 new file mode
<mode
>
1477 deleted file mode
<mode
>,
<mode
></tt></pre>
1479 <div class=
"paragraph"><p>The
<tt>mode
<mode
>,
<mode
>..
<mode
></tt> line appears only if at least one of
1480 the
<mode
> is different from the rest. Extended headers with
1481 information about detected contents movement (renames and
1482 copying detection) are designed to work with diff of two
1483 <tree-ish
> and are not used by combined diff format.
</p></div>
1487 It is followed by two-line from-file/to-file header
1489 <div class=
"literalblock">
1490 <div class=
"content">
1492 +++ b/file
</tt></pre>
1494 <div class=
"paragraph"><p>Similar to two-line header for traditional
<em>unified
</em> diff
1495 format,
<tt>/dev/null
</tt> is used to signal created or deleted
1500 Chunk header format is modified to prevent people from
1501 accidentally feeding it to
<tt>patch -p1
</tt>. Combined diff format
1502 was created for review of merge commit changes, and was not
1503 meant for apply. The change is similar to the change in the
1504 extended
<em>index
</em> header:
1506 <div class=
"literalblock">
1507 <div class=
"content">
1508 <pre><tt>@@@
<from-file-range
> <from-file-range
> <to-file-range
> @@@
</tt></pre>
1510 <div class=
"paragraph"><p>There are (number of parents +
1)
<tt>@
</tt> characters in the chunk
1511 header for combined diff format.
</p></div>
1514 <div class=
"paragraph"><p>Unlike the traditional
<em>unified
</em> diff format, which shows two
1515 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
1516 added to B), or
<tt>" "</tt> (space
 — unchanged) prefix, this format
1517 compares two or more files file1, file2,
… with one file X, and
1518 shows how X differs from each of fileN. One column for each of
1519 fileN is prepended to the output line to note how X
’s line is
1520 different from it.
</p></div>
1521 <div class=
"paragraph"><p>A
<tt>-
</tt> character in the column N means that the line appears in
1522 fileN but it does not appear in the result. A
<tt>+
</tt> character
1523 in the column N means that the line appears in the result,
1524 and fileN does not have that line (in other words, the line was
1525 added, from the point of view of that parent).
</p></div>
1526 <div class=
"paragraph"><p>In the above example output, the function signature was changed
1527 from both files (hence two
<tt>-
</tt> removals from both file1 and
1528 file2, plus
<tt>++
</tt> to mean one line that was added does not appear
1529 in either file1 nor file2). Also eight other lines are the same
1530 from file1 but do not appear in file2 (hence prefixed with
<tt>+</tt>).
</p></div>
1531 <div class=
"paragraph"><p>When shown by
<tt>git diff-tree -c
</tt>, it compares the parents of a
1532 merge commit with the merge result (i.e. file1..fileN are the
1533 parents). When shown by
<tt>git diff-files -c
</tt>, it compares the
1534 two unresolved merge parents with the working tree file
1535 (i.e. file1 is stage
2 aka
"our version", file2 is stage
3 aka
1536 "their version").
</p></div>
1538 <h2 id=
"_other_diff_formats">other diff formats
</h2>
1539 <div class=
"sectionbody">
1540 <div class=
"paragraph"><p>The
<tt>--summary
</tt> option describes newly added, deleted, renamed and
1541 copied files. The
<tt>--stat
</tt> option adds diffstat(
1) graph to the
1542 output. These options can be combined with other options, such as
1543 <tt>-p
</tt>, and are meant for human consumption.
</p></div>
1544 <div class=
"paragraph"><p>When showing a change that involves a rename or a copy,
<tt>--stat
</tt> output
1545 formats the pathnames compactly by combining common prefix and suffix of
1546 the pathnames. For example, a change that moves
<tt>arch/i386/Makefile
</tt> to
1547 <tt>arch/x86/Makefile
</tt> while modifying
4 lines will be shown like this:
</p></div>
1548 <div class=
"listingblock">
1549 <div class=
"content">
1550 <pre><tt>arch/{i386 =
> x86}/Makefile |
4 +--
</tt></pre>
1552 <div class=
"paragraph"><p>The
<tt>--numstat
</tt> option gives the diffstat(
1) information but is designed
1553 for easier machine consumption. An entry in
<tt>--numstat
</tt> output looks
1554 like this:
</p></div>
1555 <div class=
"listingblock">
1556 <div class=
"content">
1558 3 1 arch/{i386 =
> x86}/Makefile
</tt></pre>
1560 <div class=
"paragraph"><p>That is, from left to right:
</p></div>
1561 <div class=
"olist arabic"><ol class=
"arabic">
1564 the number of added lines;
1574 the number of deleted lines;
1584 pathname (possibly with rename/copy information);
1593 <div class=
"paragraph"><p>When
<tt>-z
</tt> output option is in effect, the output is formatted this way:
</p></div>
1594 <div class=
"listingblock">
1595 <div class=
"content">
1596 <pre><tt>1 2 README NUL
1597 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
</tt></pre>
1599 <div class=
"paragraph"><p>That is:
</p></div>
1600 <div class=
"olist arabic"><ol class=
"arabic">
1603 the number of added lines;
1613 the number of deleted lines;
1623 a NUL (only exists if renamed/copied);
1628 pathname in preimage;
1633 a NUL (only exists if renamed/copied);
1638 pathname in postimage (only exists if renamed/copied);
1647 <div class=
"paragraph"><p>The extra
<tt>NUL
</tt> before the preimage path in renamed case is to allow
1648 scripts that read the output to tell if the current record being read is
1649 a single-path record or a rename/copy record without reading ahead.
1650 After reading added and deleted lines, reading up to
<tt>NUL
</tt> would yield
1651 the pathname, but if that is
<tt>NUL
</tt>, the record will show two paths.
</p></div>
1653 <h2 id=
"_author">Author
</h2>
1654 <div class=
"sectionbody">
1655 <div class=
"paragraph"><p>Written by Linus Torvalds
<<a href=
"mailto:torvalds@osdl.org">torvalds@osdl.org
</a>></p></div>
1657 <h2 id=
"_documentation">Documentation
</h2>
1658 <div class=
"sectionbody">
1659 <div class=
"paragraph"><p>Documentation by David Greaves, Junio C Hamano and the git-list
<<a href=
"mailto:git@vger.kernel.org">git@vger.kernel.org
</a>>.
</p></div>
1661 <h2 id=
"_git">GIT
</h2>
1662 <div class=
"sectionbody">
1663 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1666 <div id=
"footer-text">
1667 Last updated
2010-
01-
21 17:
44:
19 UTC