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.2.5" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-diff-tree(
1)
</title>
312 git-diff-tree(
1) Manual Page
315 <div class=
"sectionbody">
317 Compares the content and mode of blobs found via two tree objects
322 <div class=
"sectionbody">
323 <div class=
"verseblock">
324 <div class=
"content"><em>git diff-tree
</em> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
325 [-t] [-r] [-c | --cc] [--root] [
<common diff options
>]
326 <tree-ish
> [
<tree-ish
>] [
<path
>…]
</div></div>
328 <h2 id=
"_description">DESCRIPTION
</h2>
329 <div class=
"sectionbody">
330 <div class=
"para"><p>Compares the content and mode of the blobs found via two tree objects.
</p></div>
331 <div class=
"para"><p>If there is only one
<tree-ish
> given, the commit is compared with its parents
332 (see --stdin below).
</p></div>
333 <div class=
"para"><p>Note that
<em>git-diff-tree
</em> can use the tree encapsulated in a commit object.
</p></div>
335 <h2 id=
"_options">OPTIONS
</h2>
336 <div class=
"sectionbody">
337 <div class=
"vlist"><dl>
346 Generate patch (see section on generating patches).
358 Generate diffs with
<n
> lines of context instead of
359 the usual three. Implies
"-p".
367 Generate the raw format.
376 Synonym for
"-p --raw".
384 Generate a diff using the
"patience diff" algorithm.
388 --stat[=width[,name-width]]
392 Generate a diffstat. You can override the default
393 output width for
80-column terminal by
"--stat=width".
394 The width of the filename part can be controlled by
395 giving another width to it separated by a comma.
403 Similar to --stat, but shows number of added and
404 deleted lines in decimal notation and pathname without
405 abbreviation, to make it more machine friendly. For
406 binary files, outputs two
<tt>-
</tt> instead of saying
415 Output only the last line of the --stat format containing total
416 number of modified files, as well as number of added and deleted
425 Output the distribution of relative amount of changes (number of lines added or
426 removed) for each sub-directory. Directories with changes below
427 a cut-off percent (
3% by default) are not shown. The cut-off percent
428 can be set with
"--dirstat=limit". Changes in a child directory is not
429 counted for the parent directory, unless
"--cumulative" is used.
433 --dirstat-by-file[=limit]
437 Same as --dirstat, but counts changed files instead of lines.
445 Output a condensed summary of extended header information
446 such as creations, renames and mode changes.
454 Synonym for
"-p --stat".
463 NUL-line termination on output. This affects the --raw
464 output field terminator. Also output from commands such
465 as
"git-log" will be delimited with NUL between commits.
473 Show only names of changed files.
481 Show only names and status of changed files. See the description
482 of the
<tt>--diff-filter
</tt> option on what the status letters mean.
498 Turn off colored diff, even when the configuration file
499 gives the default to color output.
503 --color-words[=
<regex
>]
507 Show colored word diff, i.e., color words which have changed.
508 By default, words are separated by whitespace.
510 <div class=
"para"><p>When a
<regex
> is specified, every non-overlapping match of the
511 <regex
> is considered a word. Anything between these matches is
512 considered whitespace and ignored(!) for the purposes of finding
513 differences. You may want to append
<tt>|[^[:space:]]
</tt> to your regular
514 expression to make sure that it matches all non-whitespace characters.
515 A match that contains a newline is silently truncated(!) at the
517 <div class=
"para"><p>The regex can also be set via a diff driver or configuration option, see
518 <a href=
"gitattributes.html">gitattributes(
1)
</a> or
<a href=
"git-config.html">git-config(
1)
</a>. Giving it explicitly
519 overrides any diff driver or configuration setting. Diff drivers
520 override configuration settings.
</p></div>
527 Turn off rename detection, even when the configuration
528 file gives the default to do so.
536 Warn if changes introduce trailing whitespace
537 or an indent that uses a space before a tab. Exits with
538 non-zero status if problems are found. Not compatible with
547 Instead of the first handful of characters, show the full
548 pre- and post-image blob object names on the
"index"
549 line when generating patch format output.
557 In addition to --full-index, output
"binary diff" that
558 can be applied with
"git apply".
566 Instead of showing the full
40-byte hexadecimal object
567 name in diff-raw format output and diff-tree header
568 lines, show only a partial prefix. This is
569 independent of --full-index option above, which controls
570 the diff-patch output format. Non default number of
571 digits can be specified with --abbrev=
<n
>.
579 Break complete rewrite changes into pairs of delete and create.
595 Detect copies as well as renames. See also
<tt>--find-copies-harder
</tt>.
599 --diff-filter=[ACDMRTUXB*]
603 Select only files that are Added (
<tt>A
</tt>), Copied (
<tt>C
</tt>),
604 Deleted (
<tt>D
</tt>), Modified (
<tt>M
</tt>), Renamed (
<tt>R
</tt>), have their
605 type (i.e. regular file, symlink, submodule,
…) changed (
<tt>T
</tt>),
606 are Unmerged (
<tt>U
</tt>), are
607 Unknown (
<tt>X
</tt>), or have had their pairing Broken (
<tt>B
</tt>).
608 Any combination of the filter characters may be used.
609 When
<tt>*
</tt> (All-or-none) is added to the combination, all
610 paths are selected if there is any file that matches
611 other criteria in the comparison; if there is no file
612 that matches other criteria, nothing is selected.
620 For performance reasons, by default,
<tt>-C
</tt> option finds copies only
621 if the original file of the copy was modified in the same
622 changeset. This flag makes the command
623 inspect unmodified files as candidates for the source of
624 copy. This is a very expensive operation for large
625 projects, so use it with caution. Giving more than one
626 <tt>-C
</tt> option has the same effect.
634 -M and -C options require O(n^
2) processing time where n
635 is the number of potential rename/copy targets. This
636 option prevents rename/copy detection from running if
637 the number of rename/copy targets exceeds the specified
646 Look for differences that introduce or remove an instance of
647 <string
>. Note that this is different than the string simply
648 appearing in diff output; see the
<em>pickaxe
</em> entry in
649 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a> for more details.
657 When -S finds a change, show all the changes in that
658 changeset, not just the files that contain the change
667 Make the
<string
> not a plain string but an extended POSIX
676 Output the patch in the order specified in the
677 <orderfile
>, which has one shell glob pattern per line.
685 Swap two inputs; that is, show differences from index or
686 on-disk file to tree contents.
690 --relative[=
<path
>]
694 When run from a subdirectory of the project, it can be
695 told to exclude changes outside the directory and show
696 pathnames relative to it with this option. When you are
697 not in a subdirectory (e.g. in a bare repository), you
698 can name which subdirectory to make the output relative
699 to by giving a
<path
> as an argument.
710 Treat all files as text.
714 --ignore-space-at-eol
718 Ignore changes in whitespace at EOL.
725 --ignore-space-change
729 Ignore changes in amount of whitespace. This ignores whitespace
730 at line end, and considers all other sequences of one or
731 more whitespace characters to be equivalent.
742 Ignore whitespace when comparing lines. This ignores
743 differences even if one line has whitespace where the other
748 --inter-hunk-context=
<lines
>
752 Show the context between diff hunks, up to the specified number
753 of lines, thereby fusing hunks that are close to each other.
761 Make the program exit with codes similar to diff(
1).
762 That is, it exits with
1 if there were differences and
763 0 means no differences.
771 Disable all output of the program. Implies --exit-code.
779 Allow an external diff helper to be executed. If you set an
780 external diff driver with
<a href=
"gitattributes.html">gitattributes(
5)
</a>, you need
781 to use this option with
<a href=
"git-log.html">git-log(
1)
</a> and friends.
789 Disallow external diff drivers.
797 Ignore changes to submodules in the diff generation.
801 --src-prefix=
<prefix
>
805 Show the given source prefix instead of
"a/".
809 --dst-prefix=
<prefix
>
813 Show the given destination prefix instead of
"b/".
821 Do not show any source or destination prefix.
825 <div class=
"para"><p>For more detailed explanation on these common options, see also
826 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a>.
</p></div>
827 <div class=
"vlist"><dl>
833 The id of a tree object.
841 If provided, the results are limited to a subset of files
842 matching one of these prefix strings.
843 i.e., file matches
<tt>/^
<pattern1
>|
<pattern2
>|
…/
</tt>
844 Note that this parameter does not provide any wildcard or regexp
853 recurse into sub-trees
861 show tree entry itself as well as subtrees. Implies -r.
869 When
<em>--root
</em> is specified the initial commit will be shown as a big
870 creation event. This is equivalent to a diff against the NULL tree.
878 When
<em>--stdin
</em> is specified, the command does not take
879 <tree-ish
> arguments from the command line. Instead, it
880 reads lines containing either two
<tree
>, one
<commit
>, or a
881 list of
<commit
> from its standard input. (Use a single space
884 <div class=
"para"><p>When two trees are given, it compares the first tree with the second.
885 When a single commit is given, it compares the commit with its
886 parents. The remaining commits, when given, are used as if they are
887 parents of the first commit.
</p></div>
888 <div class=
"para"><p>When comparing two trees, the ID of both trees (separated by a space
889 and terminated by a newline) is printed before the difference. When
890 comparing commits, the ID of the first (or only) commit, followed by a
891 newline, is printed.
</p></div>
892 <div class=
"para"><p>The following flags further affect the behavior when comparing
893 commits (but not trees).
</p></div>
900 By default,
<em>git-diff-tree --stdin
</em> does not show
901 differences for merge commits. With this flag, it shows
902 differences to that commit from all of its parents. See
911 By default,
<em>git-diff-tree --stdin
</em> shows differences,
912 either in machine-readable form (without
<em>-p
</em>) or in patch
913 form (with
<em>-p
</em>). This output can be suppressed. It is
914 only useful with
<em>-v
</em> flag.
922 This flag causes
<em>git-diff-tree --stdin
</em> to also show
923 the commit message before the differences.
927 --pretty[=
<em><format
></em>]
930 --format[=
<em><format
></em>]
934 Pretty-print the contents of the commit logs in a given format,
935 where
<em><format
></em> can be one of
<em>oneline
</em>,
<em>short
</em>,
<em>medium
</em>,
936 <em>full
</em>,
<em>fuller
</em>,
<em>email
</em>,
<em>raw
</em> and
<em>format:
<string
></em>.
937 When omitted, the format defaults to
<em>medium
</em>.
939 <div class=
"para"><p>Note: you can specify the default pretty format in the repository
940 configuration (see
<a href=
"git-config.html">git-config(
1)
</a>).
</p></div>
947 Instead of showing the full
40-byte hexadecimal commit object
948 name, show only a partial prefix. Non default number of
949 digits can be specified with
"--abbrev=<n>" (which also modifies
950 diff output, if it is displayed).
952 <div class=
"para"><p>This should make
"--pretty=oneline" a whole lot more readable for
953 people using
80-column terminals.
</p></div>
960 This is a shorthand for
"--pretty=oneline --abbrev-commit"
965 --encoding[=
<encoding
>]
969 The commit objects record the encoding used for the log message
970 in their encoding header; this option can be used to tell the
971 command to re-code the commit log message in the encoding
972 preferred by the user. For non plumbing commands this
981 <em>git-diff-tree
</em> outputs a line with the commit ID when
982 applicable. This flag suppressed the commit ID output.
990 This flag changes the way a merge commit is displayed
991 (which means it is useful only when the command is given
992 one
<tree-ish
>, or
<em>--stdin
</em>). It shows the differences
993 from each of the parents to the merge result simultaneously
994 instead of showing pairwise diff between a parent and the
995 result one at a time (which is what the
<em>-m
</em> option does).
996 Furthermore, it lists only files which were modified
1005 This flag changes the way a merge commit patch is displayed,
1006 in a similar way to the
<em>-c
</em> option. It implies the
<em>-c
</em>
1007 and
<em>-p
</em> options and further compresses the patch output
1008 by omitting uninteresting hunks whose the contents in the parents
1009 have only two variants and the merge result picks one of them
1010 without modification. When all hunks are uninteresting, the commit
1011 itself and the commit log message is not shown, just like in any other
1020 Show the commit itself and the commit log message even
1021 if the diff itself is empty.
1026 <h2 id=
"_pretty_formats">PRETTY FORMATS
</h2>
1027 <div class=
"sectionbody">
1028 <div class=
"para"><p>If the commit is a merge, and if the pretty-format
1029 is not
<em>oneline
</em>,
<em>email
</em> or
<em>raw
</em>, an additional line is
1030 inserted before the
<em>Author:
</em> line. This line begins with
1031 "Merge: " and the sha1s of ancestral commits are printed,
1032 separated by spaces. Note that the listed commits may not
1033 necessarily be the list of the
<strong>direct
</strong> parent commits if you
1034 have limited your view of history: for example, if you are
1035 only interested in changes related to a certain directory or
1037 <div class=
"para"><p>Here are some additional details for each format:
</p></div>
1038 <div class=
"ilist"><ul>
1043 <div class=
"literalblock">
1044 <div class=
"content">
1045 <pre><tt><sha1
> <title line
></tt></pre>
1047 <div class=
"para"><p>This is designed to be as compact as possible.
</p></div>
1053 <div class=
"literalblock">
1054 <div class=
"content">
1055 <pre><tt>commit
<sha1
>
1056 Author:
<author
></tt></pre>
1058 <div class=
"literalblock">
1059 <div class=
"content">
1060 <pre><tt><title line
></tt></pre>
1067 <div class=
"literalblock">
1068 <div class=
"content">
1069 <pre><tt>commit
<sha1
>
1070 Author:
<author
>
1071 Date:
<author date
></tt></pre>
1073 <div class=
"literalblock">
1074 <div class=
"content">
1075 <pre><tt><title line
></tt></pre>
1077 <div class=
"literalblock">
1078 <div class=
"content">
1079 <pre><tt><full commit message
></tt></pre>
1086 <div class=
"literalblock">
1087 <div class=
"content">
1088 <pre><tt>commit
<sha1
>
1089 Author:
<author
>
1090 Commit:
<committer
></tt></pre>
1092 <div class=
"literalblock">
1093 <div class=
"content">
1094 <pre><tt><title line
></tt></pre>
1096 <div class=
"literalblock">
1097 <div class=
"content">
1098 <pre><tt><full commit message
></tt></pre>
1105 <div class=
"literalblock">
1106 <div class=
"content">
1107 <pre><tt>commit
<sha1
>
1108 Author:
<author
>
1109 AuthorDate:
<author date
>
1110 Commit:
<committer
>
1111 CommitDate:
<committer date
></tt></pre>
1113 <div class=
"literalblock">
1114 <div class=
"content">
1115 <pre><tt><title line
></tt></pre>
1117 <div class=
"literalblock">
1118 <div class=
"content">
1119 <pre><tt><full commit message
></tt></pre>
1126 <div class=
"literalblock">
1127 <div class=
"content">
1128 <pre><tt>From
<sha1
> <date
>
1129 From:
<author
>
1130 Date:
<author date
>
1131 Subject: [PATCH]
<title line
></tt></pre>
1133 <div class=
"literalblock">
1134 <div class=
"content">
1135 <pre><tt><full commit message
></tt></pre>
1142 <div class=
"para"><p>The
<em>raw
</em> format shows the entire commit exactly as
1143 stored in the commit object. Notably, the SHA1s are
1144 displayed in full, regardless of whether --abbrev or
1145 --no-abbrev are used, and
<em>parents
</em> information show the
1146 true parent commits, without taking grafts nor history
1147 simplification into account.
</p></div>
1153 <div class=
"para"><p>The
<em>format:
</em> format allows you to specify which information
1154 you want to show. It works a little bit like printf format,
1155 with the notable exception that you get a newline with
<em>%n
</em>
1156 instead of
<em>\n
</em>.
</p></div>
1157 <div class=
"para"><p>E.g,
<em>format:
"The author of %h was %an, %ar%nThe title was >>%s<<%n"</em>
1158 would show something like this:
</p></div>
1159 <div class=
"listingblock">
1160 <div class=
"content">
1161 <pre><tt>The author of fe6e0ee was Junio C Hamano,
23 hours ago
1162 The title was
>>t4119: test autocomputing -p
<n
> for traditional diff input.
<<
1165 <div class=
"para"><p>The placeholders are:
</p></div>
1166 <div class=
"ilist"><ul>
1169 <em>%H
</em>: commit hash
1174 <em>%h
</em>: abbreviated commit hash
1179 <em>%T
</em>: tree hash
1184 <em>%t
</em>: abbreviated tree hash
1189 <em>%P
</em>: parent hashes
1194 <em>%p
</em>: abbreviated parent hashes
1199 <em>%an
</em>: author name
1204 <em>%aN
</em>: author name (respecting .mailmap, see
<a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1209 <em>%ae
</em>: author email
1214 <em>%aE
</em>: author email (respecting .mailmap, see
<a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1219 <em>%ad
</em>: author date (format respects --date= option)
1224 <em>%aD
</em>: author date, RFC2822 style
1229 <em>%ar
</em>: author date, relative
1234 <em>%at
</em>: author date, UNIX timestamp
1239 <em>%ai
</em>: author date, ISO
8601 format
1244 <em>%cn
</em>: committer name
1249 <em>%cN
</em>: committer name (respecting .mailmap, see
<a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1254 <em>%ce
</em>: committer email
1259 <em>%cE
</em>: committer email (respecting .mailmap, see
<a href=
"git-shortlog.html">git-shortlog(
1)
</a> or
<a href=
"git-blame.html">git-blame(
1)
</a>)
1264 <em>%cd
</em>: committer date
1269 <em>%cD
</em>: committer date, RFC2822 style
1274 <em>%cr
</em>: committer date, relative
1279 <em>%ct
</em>: committer date, UNIX timestamp
1284 <em>%ci
</em>: committer date, ISO
8601 format
1289 <em>%d
</em>: ref names, like the --decorate option of
<a href=
"git-log.html">git-log(
1)
</a>
1294 <em>%e
</em>: encoding
1299 <em>%s
</em>: subject
1304 <em>%f
</em>: sanitized subject line, suitable for a filename
1314 <em>%Cred
</em>: switch color to red
1319 <em>%Cgreen
</em>: switch color to green
1324 <em>%Cblue
</em>: switch color to blue
1329 <em>%Creset
</em>: reset color
1334 <em>%C(
…)
</em>: color specification, as described in color.branch.* config option
1339 <em>%m
</em>: left, right or boundary mark
1344 <em>%n
</em>: newline
1349 <em>%x00
</em>: print a byte from a hex code
1358 <div class=
"para"><p>The
<em>tformat:
</em> format works exactly like
<em>format:
</em>, except that it
1359 provides
"terminator" semantics instead of
"separator" semantics. In
1360 other words, each commit has the message terminator character (usually a
1361 newline) appended, rather than a separator placed between entries.
1362 This means that the final entry of a single-line format will be properly
1363 terminated with a new line, just as the
"oneline" format does.
1364 For example:
</p></div>
1365 <div class=
"listingblock">
1366 <div class=
"content">
1367 <pre><tt>$ git log -
2 --pretty=format:%h
4da45bef \
1368 | perl -pe '$_ .=
" -- NO NEWLINE\n" unless /\n/'
1370 7134973 -- NO NEWLINE
1372 $ git log -
2 --pretty=tformat:%h
4da45bef \
1373 | perl -pe '$_ .=
" -- NO NEWLINE\n" unless /\n/'
1377 <div class=
"para"><p>In addition, any unrecognized string that has a
<tt>%
</tt> in it is interpreted
1378 as if it has
<tt>tformat:
</tt> in front of it. For example, these two are
1379 equivalent:
</p></div>
1380 <div class=
"listingblock">
1381 <div class=
"content">
1382 <pre><tt>$ git log -
2 --pretty=tformat:%h
4da45bef
1383 $ git log -
2 --pretty=%h
4da45bef
</tt></pre>
1388 <h2 id=
"_limiting_output">Limiting Output
</h2>
1389 <div class=
"sectionbody">
1390 <div class=
"para"><p>If you're only interested in differences in a subset of files, for
1391 example some architecture-specific files, you might do:
</p></div>
1392 <div class=
"literalblock">
1393 <div class=
"content">
1394 <pre><tt>git diff-tree -r
<tree-ish
> <tree-ish
> arch/ia64 include/asm-ia64
</tt></pre>
1396 <div class=
"para"><p>and it will only show you what changed in those two directories.
</p></div>
1397 <div class=
"para"><p>Or if you are searching for what changed in just
<tt>kernel/sched.c
</tt>, just do
</p></div>
1398 <div class=
"literalblock">
1399 <div class=
"content">
1400 <pre><tt>git diff-tree -r
<tree-ish
> <tree-ish
> kernel/sched.c
</tt></pre>
1402 <div class=
"para"><p>and it will ignore all differences to other files.
</p></div>
1403 <div class=
"para"><p>The pattern is always the prefix, and is matched exactly. There are no
1404 wildcards. Even stricter, it has to match a complete path component.
1405 I.e.
"foo" does not pick up
<tt>foobar.h
</tt>.
"foo" does match
<tt>foo/bar.h
</tt>
1406 so it can be used to name subdirectories.
</p></div>
1407 <div class=
"para"><p>An example of normal usage is:
</p></div>
1408 <div class=
"literalblock">
1409 <div class=
"content">
1410 <pre><tt>torvalds@ppc970:~/git
> git diff-tree
5319e4......
1411 *
100664-
>100664 blob ac348b.......-
>a01513....... git-fsck-objects.c
</tt></pre>
1413 <div class=
"para"><p>which tells you that the last commit changed just one file (it's from
1415 <div class=
"listingblock">
1416 <div class=
"content">
1417 <pre><tt>commit
3c6f7ca19ad4043e9e72fa94106f352897e651a8
1418 tree
5319e4d609cdd282069cc4dce33c1db559539b03
1419 parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1420 author Linus Torvalds
<torvalds@ppc970.osdl.org
> Sat Apr
9 12:
02:
30 2005
1421 committer Linus Torvalds
<torvalds@ppc970.osdl.org
> Sat Apr
9 12:
02:
30 2005
1423 Make
"git-fsck-objects" print out all the root commits it finds.
1425 Once I do the reference tracking, I'll also make it print out all the
1426 HEAD commits it finds, which is even more interesting.
</tt></pre>
1428 <div class=
"para"><p>in case you care).
</p></div>
1430 <h2 id=
"_output_format">Output format
</h2>
1431 <div class=
"sectionbody">
1432 <div class=
"para"><p>The output format from
"git-diff-index",
"git-diff-tree",
1433 "git-diff-files" and
"git diff --raw" are very similar.
</p></div>
1434 <div class=
"para"><p>These commands all compare two sets of things; what is
1435 compared differs:
</p></div>
1436 <div class=
"vlist"><dl>
1438 git-diff-index
<tree-ish
>
1442 compares the
<tree-ish
> and the files on the filesystem.
1446 git-diff-index --cached
<tree-ish
>
1450 compares the
<tree-ish
> and the index.
1454 git-diff-tree [-r]
<tree-ish-
1> <tree-ish-
2> [
<pattern
>…]
1458 compares the trees named by the two arguments.
1462 git-diff-files [
<pattern
>…]
1466 compares the index and the files on the filesystem.
1470 <div class=
"para"><p>An output line is formatted this way:
</p></div>
1471 <div class=
"listingblock">
1472 <div class=
"content">
1473 <pre><tt>in-place edit :
100644 100644 bcd1234...
0123456... M file0
1474 copy-edit :
100644 100644 abcd123...
1234567... C68 file1 file2
1475 rename-edit :
100644 100644 abcd123...
1234567... R86 file1 file3
1476 create :
000000 100644 0000000...
1234567... A file4
1477 delete :
100644 000000 1234567...
0000000... D file5
1478 unmerged :
000000 000000 0000000...
0000000... U file6
</tt></pre>
1480 <div class=
"para"><p>That is, from the left to the right:
</p></div>
1481 <div class=
"olist"><ol>
1489 mode for
"src";
000000 if creation or unmerged.
1499 mode for
"dst";
000000 if deletion or unmerged.
1509 sha1 for
"src";
0{
40} if creation or unmerged.
1519 sha1 for
"dst";
0{
40} if creation, unmerged or
"look at work tree".
1529 status, followed by optional
"score" number.
1534 a tab or a NUL when
<em>-z
</em> option is used.
1544 a tab or a NUL when
<em>-z
</em> option is used; only exists for C or R.
1549 path for
"dst"; only exists for C or R.
1554 an LF or a NUL when
<em>-z
</em> option is used, to terminate the record.
1558 <div class=
"para"><p>Possible status letters are:
</p></div>
1559 <div class=
"ilist"><ul>
1562 A: addition of a file
1567 C: copy of a file into a new one
1572 D: deletion of a file
1577 M: modification of the contents or mode of a file
1582 R: renaming of a file
1587 T: change in the type of the file
1592 U: file is unmerged (you must complete the merge before it can
1598 X:
"unknown" change type (most probably a bug, please report it)
1602 <div class=
"para"><p>Status letters C and R are always followed by a score (denoting the
1603 percentage of similarity between the source and target of the move or
1604 copy), and are the only ones to be so.
</p></div>
1605 <div class=
"para"><p><sha1
> is shown as all
0's if a file is new on the filesystem
1606 and it is out of sync with the index.
</p></div>
1607 <div class=
"para"><p>Example:
</p></div>
1608 <div class=
"listingblock">
1609 <div class=
"content">
1610 <pre><tt>:
100644 100644 5be4a4......
000000...... M file.c
</tt></pre>
1612 <div class=
"para"><p>When
<tt>-z
</tt> option is not used, TAB, LF, and backslash characters
1613 in pathnames are represented as
<tt>\t
</tt>,
<tt>\n
</tt>, and
<tt>\\
</tt>,
1614 respectively.
</p></div>
1616 <h2 id=
"_diff_format_for_merges">diff format for merges
</h2>
1617 <div class=
"sectionbody">
1618 <div class=
"para"><p>"git-diff-tree",
"git-diff-files" and
"git-diff --raw"
1619 can take
<em>-c
</em> or
<em>--cc
</em> option
1620 to generate diff output also for merge commits. The output differs
1621 from the format described above in the following way:
</p></div>
1622 <div class=
"olist"><ol>
1625 there is a colon for each parent
1630 there are more
"src" modes and
"src" sha1
1635 status is concatenated status characters for each parent
1640 no optional
"score" number
1645 single path, only for
"dst"
1649 <div class=
"para"><p>Example:
</p></div>
1650 <div class=
"listingblock">
1651 <div class=
"content">
1652 <pre><tt>::
100644 100644 100644 fabadb8... cc95eb0...
4866510... MM describe.c
</tt></pre>
1654 <div class=
"para"><p>Note that
<em>combined diff
</em> lists only files which were modified from
1655 all parents.
</p></div>
1657 <h2 id=
"_generating_patches_with_p">Generating patches with -p
</h2>
1658 <div class=
"sectionbody">
1659 <div class=
"para"><p>When
"git-diff-index",
"git-diff-tree", or
"git-diff-files" are run
1660 with a
<em>-p
</em> option,
"git diff" without the
<em>--raw
</em> option, or
1661 "git log" with the
"-p" option, they
1662 do not produce the output described above; instead they produce a
1663 patch file. You can customize the creation of such patches via the
1664 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.
</p></div>
1665 <div class=
"para"><p>What the -p option produces is slightly different from the traditional
1666 diff format.
</p></div>
1667 <div class=
"olist"><ol>
1670 It is preceded with a
"git diff" header, that looks like
1673 <div class=
"literalblock">
1674 <div class=
"content">
1675 <pre><tt>diff --git a/file1 b/file2
</tt></pre>
1677 <div class=
"para"><p>The
<tt>a/
</tt> and
<tt>b/
</tt> filenames are the same unless rename/copy is
1678 involved. Especially, even for a creation or a deletion,
1679 <tt>/dev/null
</tt> is _not_ used in place of
<tt>a/
</tt> or
<tt>b/
</tt> filenames.
</p></div>
1680 <div class=
"para"><p>When rename/copy is involved,
<tt>file1
</tt> and
<tt>file2
</tt> show the
1681 name of the source file of the rename/copy and the name of
1682 the file that rename/copy produces, respectively.
</p></div>
1686 It is followed by one or more extended header lines:
1688 <div class=
"literalblock">
1689 <div class=
"content">
1690 <pre><tt>old mode
<mode
>
1691 new mode
<mode
>
1692 deleted file mode
<mode
>
1693 new file mode
<mode
>
1694 copy from
<path
>
1695 copy to
<path
>
1696 rename from
<path
>
1697 rename to
<path
>
1698 similarity index
<number
>
1699 dissimilarity index
<number
>
1700 index
<hash
>..
<hash
> <mode
></tt></pre>
1705 TAB, LF, double quote and backslash characters in pathnames
1706 are represented as
<tt>\t
</tt>,
<tt>\n
</tt>,
<tt>\
"</tt> and <tt>\\</tt>, respectively.
1707 If there is need for such substitution then the whole
1708 pathname is put in double quotes.
1712 <div class="para
"><p>The similarity index is the percentage of unchanged lines, and
1713 the dissimilarity index is the percentage of changed lines. It
1714 is a rounded down integer, followed by a percent sign. The
1715 similarity index value of 100% is thus reserved for two equal
1716 files, while 100% dissimilarity means that no line from the old
1717 file made it into the new one.</p></div>
1719 <h2 id="_combined_diff_format
">combined diff format</h2>
1720 <div class="sectionbody
">
1721 <div class="para
"><p>"git-diff-tree
", "git-diff-files
" and "git-diff
" can take <em>-c</em> or
1722 <em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1723 with "git log -p
", this is the default format.
1724 A <em>combined diff</em> format looks like this:</p></div>
1725 <div class="listingblock
">
1726 <div class="content
">
1727 <pre><tt>diff --combined describe.c
1728 index fabadb8,cc95eb0..4866510
1731 @@@ -98,20 -98,12 +98,20 @@@
1732 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1735 - static void describe(char *arg)
1736 -static void describe(struct commit *cmit, int last_one)
1737 ++static void describe(char *arg, int last_one)
1739 + unsigned char sha1[20];
1740 + struct commit *cmit;
1741 struct commit_list *list;
1742 static int initialized = 0;
1743 struct commit_name *n;
1745 + if (get_sha1(arg, sha1) < 0)
1746 + usage(describe_usage);
1747 + cmit = lookup_commit_reference(sha1);
1749 + usage(describe_usage);
1753 for_each_ref(get_name);</tt></pre>
1755 <div class="olist
"><ol>
1758 It is preceded with a "git diff
" header, that looks like
1759 this (when <em>-c</em> option is used):
1761 <div class="literalblock
">
1762 <div class="content
">
1763 <pre><tt>diff --combined file</tt></pre>
1765 <div class="para
"><p>or like this (when <em>--cc</em> option is used):</p></div>
1766 <div class="literalblock
">
1767 <div class="content
">
1768 <pre><tt>diff --cc file</tt></pre>
1773 It is followed by one or more extended header lines
1774 (this example shows a merge with two parents):
1776 <div class="literalblock
">
1777 <div class="content
">
1778 <pre><tt>index <hash>,<hash>..<hash>
1779 mode <mode>,<mode>..<mode>
1780 new file mode <mode>
1781 deleted file mode <mode>,<mode></tt></pre>
1783 <div class="para
"><p>The <tt>mode <mode>,<mode>..<mode></tt> line appears only if at least one of
1784 the <mode> is different from the rest. Extended headers with
1785 information about detected contents movement (renames and
1786 copying detection) are designed to work with diff of two
1787 <tree-ish> and are not used by combined diff format.</p></div>
1791 It is followed by two-line from-file/to-file header
1793 <div class="literalblock
">
1794 <div class="content
">
1796 +++ b/file</tt></pre>
1798 <div class="para
"><p>Similar to two-line header for traditional <em>unified</em> diff
1799 format, <tt>/dev/null</tt> is used to signal created or deleted
1804 Chunk header format is modified to prevent people from
1805 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1806 was created for review of merge commit changes, and was not
1807 meant for apply. The change is similar to the change in the
1808 extended <em>index</em> header:
1810 <div class="literalblock
">
1811 <div class="content
">
1812 <pre><tt>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</tt></pre>
1814 <div class="para
"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1815 header for combined diff format.</p></div>
1818 <div class="para
"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1819 files A and B with a single column that has <tt>-</tt> (minus —
1820 appears in A but removed in B), <tt>+</tt> (plus — missing in A but
1821 added to B), or <tt>" "</tt> (space — unchanged) prefix, this format
1822 compares two or more files file1, file2,… with one file X, and
1823 shows how X differs from each of fileN. One column for each of
1824 fileN is prepended to the output line to note how X's line is
1825 different from it.</p></div>
1826 <div class="para
"><p>A <tt>-</tt> character in the column N means that the line appears in
1827 fileN but it does not appear in the result. A <tt>+</tt> character
1828 in the column N means that the line appears in the result,
1829 and fileN does not have that line (in other words, the line was
1830 added, from the point of view of that parent).</p></div>
1831 <div class="para
"><p>In the above example output, the function signature was changed
1832 from both files (hence two <tt>-</tt> removals from both file1 and
1833 file2, plus <tt>++</tt> to mean one line that was added does not appear
1834 in either file1 nor file2). Also eight other lines are the same
1835 from file1 but do not appear in file2 (hence prefixed with <tt>+</tt>).</p></div>
1836 <div class="para
"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1837 merge commit with the merge result (i.e. file1..fileN are the
1838 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1839 two unresolved merge parents with the working tree file
1840 (i.e. file1 is stage 2 aka "our version
", file2 is stage 3 aka
1841 "their version
").</p></div>
1843 <h2 id="_other_diff_formats
">other diff formats</h2>
1844 <div class="sectionbody
">
1845 <div class="para
"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1846 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1847 output. These options can be combined with other options, such as
1848 <tt>-p</tt>, and are meant for human consumption.</p></div>
1849 <div class="para
"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1850 formats the pathnames compactly by combining common prefix and suffix of
1851 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1852 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1853 <div class="listingblock
">
1854 <div class="content
">
1855 <pre><tt>arch/{i386 => x86}/Makefile | 4 +--</tt></pre>
1857 <div class="para
"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1858 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1859 like this:</p></div>
1860 <div class="listingblock
">
1861 <div class="content
">
1863 3 1 arch/{i386 => x86}/Makefile</tt></pre>
1865 <div class="para
"><p>That is, from left to right:</p></div>
1866 <div class="olist
"><ol>
1869 the number of added lines;
1879 the number of deleted lines;
1889 pathname (possibly with rename/copy information);
1898 <div class="para
"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1899 <div class="listingblock
">
1900 <div class="content
">
1901 <pre><tt>1 2 README NUL
1902 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1904 <div class="para
"><p>That is:</p></div>
1905 <div class="olist
"><ol>
1908 the number of added lines;
1918 the number of deleted lines;
1928 a NUL (only exists if renamed/copied);
1933 pathname in preimage;
1938 a NUL (only exists if renamed/copied);
1943 pathname in postimage (only exists if renamed/copied);
1952 <div class="para
"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1953 scripts that read the output to tell if the current record being read is
1954 a single-path record or a rename/copy record without reading ahead.
1955 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1956 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1958 <h2 id="_author
">Author</h2>
1959 <div class="sectionbody
">
1960 <div class="para
"><p>Written by Linus Torvalds <torvalds@osdl.org></p></div>
1962 <h2 id="_documentation
">Documentation</h2>
1963 <div class="sectionbody
">
1964 <div class="para
"><p>Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.</p></div>
1966 <h2 id="_git
">GIT</h2>
1967 <div class="sectionbody
">
1968 <div class="para
"><p>Part of the <a href="git.html
">git(1)</a> suite</p></div>
1971 <div id="footer-text
">
1972 Last updated 2009-07-01 02:30:48 UTC