1GIT-DIFF-TREE(1)                  Git Manual                  GIT-DIFF-TREE(1)
2
3
4

NAME

6       git-diff-tree - Compares the content and mode of blobs found via two
7       tree objects
8

SYNOPSIS

10       git diff-tree [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
11                     [-t] [-r] [-c | --cc] [--combined-all-paths] [--root]
12                     [<common diff options>] <tree-ish> [<tree-ish>] [<path>...]
13

DESCRIPTION

15       Compares the content and mode of the blobs found via two tree objects.
16
17       If there is only one <tree-ish> given, the commit is compared with its
18       parents (see --stdin below).
19
20       Note that git diff-tree can use the tree encapsulated in a commit
21       object.
22

OPTIONS

24       -p, -u, --patch
25           Generate patch (see section on generating patches).
26
27       -s, --no-patch
28           Suppress diff output. Useful for commands like git show that show
29           the patch by default, or to cancel the effect of --patch.
30
31       -U<n>, --unified=<n>
32           Generate diffs with <n> lines of context instead of the usual
33           three. Implies --patch. Implies -p.
34
35       --output=<file>
36           Output to a specific file instead of stdout.
37
38       --output-indicator-new=<char>, --output-indicator-old=<char>,
39       --output-indicator-context=<char>
40           Specify the character used to indicate new, old or context lines in
41           the generated patch. Normally they are +, - and ' ' respectively.
42
43       --raw
44           Generate the diff in raw format. This is the default.
45
46       --patch-with-raw
47           Synonym for -p --raw.
48
49       --indent-heuristic
50           Enable the heuristic that shifts diff hunk boundaries to make
51           patches easier to read. This is the default.
52
53       --no-indent-heuristic
54           Disable the indent heuristic.
55
56       --minimal
57           Spend extra time to make sure the smallest possible diff is
58           produced.
59
60       --patience
61           Generate a diff using the "patience diff" algorithm.
62
63       --histogram
64           Generate a diff using the "histogram diff" algorithm.
65
66       --anchored=<text>
67           Generate a diff using the "anchored diff" algorithm.
68
69           This option may be specified more than once.
70
71           If a line exists in both the source and destination, exists only
72           once, and starts with this text, this algorithm attempts to prevent
73           it from appearing as a deletion or addition in the output. It uses
74           the "patience diff" algorithm internally.
75
76       --diff-algorithm={patience|minimal|histogram|myers}
77           Choose a diff algorithm. The variants are as follows:
78
79           default, myers
80               The basic greedy diff algorithm. Currently, this is the
81               default.
82
83           minimal
84               Spend extra time to make sure the smallest possible diff is
85               produced.
86
87           patience
88               Use "patience diff" algorithm when generating patches.
89
90           histogram
91               This algorithm extends the patience algorithm to "support
92               low-occurrence common elements".
93
94           For instance, if you configured the diff.algorithm variable to a
95           non-default value and want to use the default one, then you have to
96           use --diff-algorithm=default option.
97
98       --stat[=<width>[,<name-width>[,<count>]]]
99           Generate a diffstat. By default, as much space as necessary will be
100           used for the filename part, and the rest for the graph part.
101           Maximum width defaults to terminal width, or 80 columns if not
102           connected to a terminal, and can be overridden by <width>. The
103           width of the filename part can be limited by giving another width
104           <name-width> after a comma. The width of the graph part can be
105           limited by using --stat-graph-width=<width> (affects all commands
106           generating a stat graph) or by setting diff.statGraphWidth=<width>
107           (does not affect git format-patch). By giving a third parameter
108           <count>, you can limit the output to the first <count> lines,
109           followed by ...  if there are more.
110
111           These parameters can also be set individually with
112           --stat-width=<width>, --stat-name-width=<name-width> and
113           --stat-count=<count>.
114
115       --compact-summary
116           Output a condensed summary of extended header information such as
117           file creations or deletions ("new" or "gone", optionally "+l" if
118           it’s a symlink) and mode changes ("+x" or "-x" for adding or
119           removing executable bit respectively) in diffstat. The information
120           is put between the filename part and the graph part. Implies
121           --stat.
122
123       --numstat
124           Similar to --stat, but shows number of added and deleted lines in
125           decimal notation and pathname without abbreviation, to make it more
126           machine friendly. For binary files, outputs two - instead of saying
127           0 0.
128
129       --shortstat
130           Output only the last line of the --stat format containing total
131           number of modified files, as well as number of added and deleted
132           lines.
133
134       -X[<param1,param2,...>], --dirstat[=<param1,param2,...>]
135           Output the distribution of relative amount of changes for each
136           sub-directory. The behavior of --dirstat can be customized by
137           passing it a comma separated list of parameters. The defaults are
138           controlled by the diff.dirstat configuration variable (see git-
139           config(1)). The following parameters are available:
140
141           changes
142               Compute the dirstat numbers by counting the lines that have
143               been removed from the source, or added to the destination. This
144               ignores the amount of pure code movements within a file. In
145               other words, rearranging lines in a file is not counted as much
146               as other changes. This is the default behavior when no
147               parameter is given.
148
149           lines
150               Compute the dirstat numbers by doing the regular line-based
151               diff analysis, and summing the removed/added line counts. (For
152               binary files, count 64-byte chunks instead, since binary files
153               have no natural concept of lines). This is a more expensive
154               --dirstat behavior than the changes behavior, but it does count
155               rearranged lines within a file as much as other changes. The
156               resulting output is consistent with what you get from the other
157               --*stat options.
158
159           files
160               Compute the dirstat numbers by counting the number of files
161               changed. Each changed file counts equally in the dirstat
162               analysis. This is the computationally cheapest --dirstat
163               behavior, since it does not have to look at the file contents
164               at all.
165
166           cumulative
167               Count changes in a child directory for the parent directory as
168               well. Note that when using cumulative, the sum of the
169               percentages reported may exceed 100%. The default
170               (non-cumulative) behavior can be specified with the
171               noncumulative parameter.
172
173           <limit>
174               An integer parameter specifies a cut-off percent (3% by
175               default). Directories contributing less than this percentage of
176               the changes are not shown in the output.
177
178           Example: The following will count changed files, while ignoring
179           directories with less than 10% of the total amount of changed
180           files, and accumulating child directory counts in the parent
181           directories: --dirstat=files,10,cumulative.
182
183       --cumulative
184           Synonym for --dirstat=cumulative
185
186       --dirstat-by-file[=<param1,param2>...]
187           Synonym for --dirstat=files,param1,param2...
188
189       --summary
190           Output a condensed summary of extended header information such as
191           creations, renames and mode changes.
192
193       --patch-with-stat
194           Synonym for -p --stat.
195
196       -z
197           When --raw, --numstat, --name-only or --name-status has been given,
198           do not munge pathnames and use NULs as output field terminators.
199
200           Without this option, pathnames with "unusual" characters are quoted
201           as explained for the configuration variable core.quotePath (see
202           git-config(1)).
203
204       --name-only
205           Show only names of changed files.
206
207       --name-status
208           Show only names and status of changed files. See the description of
209           the --diff-filter option on what the status letters mean.
210
211       --submodule[=<format>]
212           Specify how differences in submodules are shown. When specifying
213           --submodule=short the short format is used. This format just shows
214           the names of the commits at the beginning and end of the range.
215           When --submodule or --submodule=log is specified, the log format is
216           used. This format lists the commits in the range like git-
217           submodule(1) summary does. When --submodule=diff is specified, the
218           diff format is used. This format shows an inline diff of the
219           changes in the submodule contents between the commit range.
220           Defaults to diff.submodule or the short format if the config option
221           is unset.
222
223       --color[=<when>]
224           Show colored diff.  --color (i.e. without =<when>) is the same as
225           --color=always.  <when> can be one of always, never, or auto.
226
227       --no-color
228           Turn off colored diff. It is the same as --color=never.
229
230       --color-moved[=<mode>]
231           Moved lines of code are colored differently. The <mode> defaults to
232           no if the option is not given and to zebra if the option with no
233           mode is given. The mode must be one of:
234
235           no
236               Moved lines are not highlighted.
237
238           default
239               Is a synonym for zebra. This may change to a more sensible mode
240               in the future.
241
242           plain
243               Any line that is added in one location and was removed in
244               another location will be colored with color.diff.newMoved.
245               Similarly color.diff.oldMoved will be used for removed lines
246               that are added somewhere else in the diff. This mode picks up
247               any moved line, but it is not very useful in a review to
248               determine if a block of code was moved without permutation.
249
250           blocks
251               Blocks of moved text of at least 20 alphanumeric characters are
252               detected greedily. The detected blocks are painted using either
253               the color.diff.{old,new}Moved color. Adjacent blocks cannot be
254               told apart.
255
256           zebra
257               Blocks of moved text are detected as in blocks mode. The blocks
258               are painted using either the color.diff.{old,new}Moved color or
259               color.diff.{old,new}MovedAlternative. The change between the
260               two colors indicates that a new block was detected.
261
262           dimmed-zebra
263               Similar to zebra, but additional dimming of uninteresting parts
264               of moved code is performed. The bordering lines of two adjacent
265               blocks are considered interesting, the rest is uninteresting.
266               dimmed_zebra is a deprecated synonym.
267
268       --no-color-moved
269           Turn off move detection. This can be used to override configuration
270           settings. It is the same as --color-moved=no.
271
272       --color-moved-ws=<modes>
273           This configures how whitespace is ignored when performing the move
274           detection for --color-moved. These modes can be given as a comma
275           separated list:
276
277           no
278               Do not ignore whitespace when performing move detection.
279
280           ignore-space-at-eol
281               Ignore changes in whitespace at EOL.
282
283           ignore-space-change
284               Ignore changes in amount of whitespace. This ignores whitespace
285               at line end, and considers all other sequences of one or more
286               whitespace characters to be equivalent.
287
288           ignore-all-space
289               Ignore whitespace when comparing lines. This ignores
290               differences even if one line has whitespace where the other
291               line has none.
292
293           allow-indentation-change
294               Initially ignore any whitespace in the move detection, then
295               group the moved code blocks only into a block if the change in
296               whitespace is the same per line. This is incompatible with the
297               other modes.
298
299       --no-color-moved-ws
300           Do not ignore whitespace when performing move detection. This can
301           be used to override configuration settings. It is the same as
302           --color-moved-ws=no.
303
304       --word-diff[=<mode>]
305           Show a word diff, using the <mode> to delimit changed words. By
306           default, words are delimited by whitespace; see --word-diff-regex
307           below. The <mode> defaults to plain, and must be one of:
308
309           color
310               Highlight changed words using only colors. Implies --color.
311
312           plain
313               Show words as [-removed-] and {+added+}. Makes no attempts to
314               escape the delimiters if they appear in the input, so the
315               output may be ambiguous.
316
317           porcelain
318               Use a special line-based format intended for script
319               consumption. Added/removed/unchanged runs are printed in the
320               usual unified diff format, starting with a +/-/` ` character at
321               the beginning of the line and extending to the end of the line.
322               Newlines in the input are represented by a tilde ~ on a line of
323               its own.
324
325           none
326               Disable word diff again.
327
328           Note that despite the name of the first mode, color is used to
329           highlight the changed parts in all modes if enabled.
330
331       --word-diff-regex=<regex>
332           Use <regex> to decide what a word is, instead of considering runs
333           of non-whitespace to be a word. Also implies --word-diff unless it
334           was already enabled.
335
336           Every non-overlapping match of the <regex> is considered a word.
337           Anything between these matches is considered whitespace and
338           ignored(!) for the purposes of finding differences. You may want to
339           append |[^[:space:]] to your regular expression to make sure that
340           it matches all non-whitespace characters. A match that contains a
341           newline is silently truncated(!) at the newline.
342
343           For example, --word-diff-regex=.  will treat each character as a
344           word and, correspondingly, show differences character by character.
345
346           The regex can also be set via a diff driver or configuration
347           option, see gitattributes(5) or git-config(1). Giving it explicitly
348           overrides any diff driver or configuration setting. Diff drivers
349           override configuration settings.
350
351       --color-words[=<regex>]
352           Equivalent to --word-diff=color plus (if a regex was specified)
353           --word-diff-regex=<regex>.
354
355       --no-renames
356           Turn off rename detection, even when the configuration file gives
357           the default to do so.
358
359       --[no-]rename-empty
360           Whether to use empty blobs as rename source.
361
362       --check
363           Warn if changes introduce conflict markers or whitespace errors.
364           What are considered whitespace errors is controlled by
365           core.whitespace configuration. By default, trailing whitespaces
366           (including lines that consist solely of whitespaces) and a space
367           character that is immediately followed by a tab character inside
368           the initial indent of the line are considered whitespace errors.
369           Exits with non-zero status if problems are found. Not compatible
370           with --exit-code.
371
372       --ws-error-highlight=<kind>
373           Highlight whitespace errors in the context, old or new lines of the
374           diff. Multiple values are separated by comma, none resets previous
375           values, default reset the list to new and all is a shorthand for
376           old,new,context. When this option is not given, and the
377           configuration variable diff.wsErrorHighlight is not set, only
378           whitespace errors in new lines are highlighted. The whitespace
379           errors are colored with color.diff.whitespace.
380
381       --full-index
382           Instead of the first handful of characters, show the full pre- and
383           post-image blob object names on the "index" line when generating
384           patch format output.
385
386       --binary
387           In addition to --full-index, output a binary diff that can be
388           applied with git-apply. Implies --patch.
389
390       --abbrev[=<n>]
391           Instead of showing the full 40-byte hexadecimal object name in
392           diff-raw format output and diff-tree header lines, show only a
393           partial prefix. This is independent of the --full-index option
394           above, which controls the diff-patch output format. Non default
395           number of digits can be specified with --abbrev=<n>.
396
397       -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
398           Break complete rewrite changes into pairs of delete and create.
399           This serves two purposes:
400
401           It affects the way a change that amounts to a total rewrite of a
402           file not as a series of deletion and insertion mixed together with
403           a very few lines that happen to match textually as the context, but
404           as a single deletion of everything old followed by a single
405           insertion of everything new, and the number m controls this aspect
406           of the -B option (defaults to 60%).  -B/70% specifies that less
407           than 30% of the original should remain in the result for Git to
408           consider it a total rewrite (i.e. otherwise the resulting patch
409           will be a series of deletion and insertion mixed together with
410           context lines).
411
412           When used with -M, a totally-rewritten file is also considered as
413           the source of a rename (usually -M only considers a file that
414           disappeared as the source of a rename), and the number n controls
415           this aspect of the -B option (defaults to 50%).  -B20% specifies
416           that a change with addition and deletion compared to 20% or more of
417           the file’s size are eligible for being picked up as a possible
418           source of a rename to another file.
419
420       -M[<n>], --find-renames[=<n>]
421           Detect renames. If n is specified, it is a threshold on the
422           similarity index (i.e. amount of addition/deletions compared to the
423           file’s size). For example, -M90% means Git should consider a
424           delete/add pair to be a rename if more than 90% of the file hasn’t
425           changed. Without a % sign, the number is to be read as a fraction,
426           with a decimal point before it. I.e., -M5 becomes 0.5, and is thus
427           the same as -M50%. Similarly, -M05 is the same as -M5%. To limit
428           detection to exact renames, use -M100%. The default similarity
429           index is 50%.
430
431       -C[<n>], --find-copies[=<n>]
432           Detect copies as well as renames. See also --find-copies-harder. If
433           n is specified, it has the same meaning as for -M<n>.
434
435       --find-copies-harder
436           For performance reasons, by default, -C option finds copies only if
437           the original file of the copy was modified in the same changeset.
438           This flag makes the command inspect unmodified files as candidates
439           for the source of copy. This is a very expensive operation for
440           large projects, so use it with caution. Giving more than one -C
441           option has the same effect.
442
443       -D, --irreversible-delete
444           Omit the preimage for deletes, i.e. print only the header but not
445           the diff between the preimage and /dev/null. The resulting patch is
446           not meant to be applied with patch or git apply; this is solely for
447           people who want to just concentrate on reviewing the text after the
448           change. In addition, the output obviously lacks enough information
449           to apply such a patch in reverse, even manually, hence the name of
450           the option.
451
452           When used together with -B, omit also the preimage in the deletion
453           part of a delete/create pair.
454
455       -l<num>
456           The -M and -C options require O(n^2) processing time where n is the
457           number of potential rename/copy targets. This option prevents
458           rename/copy detection from running if the number of rename/copy
459           targets exceeds the specified number.
460
461       --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
462           Select only files that are Added (A), Copied (C), Deleted (D),
463           Modified (M), Renamed (R), have their type (i.e. regular file,
464           symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
465           (X), or have had their pairing Broken (B). Any combination of the
466           filter characters (including none) can be used. When *
467           (All-or-none) is added to the combination, all paths are selected
468           if there is any file that matches other criteria in the comparison;
469           if there is no file that matches other criteria, nothing is
470           selected.
471
472           Also, these upper-case letters can be downcased to exclude. E.g.
473           --diff-filter=ad excludes added and deleted paths.
474
475           Note that not all diffs can feature all types. For instance, diffs
476           from the index to the working tree can never have Added entries
477           (because the set of paths included in the diff is limited by what
478           is in the index). Similarly, copied and renamed entries cannot
479           appear if detection for those types is disabled.
480
481       -S<string>
482           Look for differences that change the number of occurrences of the
483           specified string (i.e. addition/deletion) in a file. Intended for
484           the scripter’s use.
485
486           It is useful when you’re looking for an exact block of code (like a
487           struct), and want to know the history of that block since it first
488           came into being: use the feature iteratively to feed the
489           interesting block in the preimage back into -S, and keep going
490           until you get the very first version of the block.
491
492           Binary files are searched as well.
493
494       -G<regex>
495           Look for differences whose patch text contains added/removed lines
496           that match <regex>.
497
498           To illustrate the difference between -S<regex> --pickaxe-regex and
499           -G<regex>, consider a commit with the following diff in the same
500           file:
501
502               +    return frotz(nitfol, two->ptr, 1, 0);
503               ...
504               -    hit = frotz(nitfol, mf2.ptr, 1, 0);
505
506           While git log -G"frotz\(nitfol" will show this commit, git log
507           -S"frotz\(nitfol" --pickaxe-regex will not (because the number of
508           occurrences of that string did not change).
509
510           Unless --text is supplied patches of binary files without a
511           textconv filter will be ignored.
512
513           See the pickaxe entry in gitdiffcore(7) for more information.
514
515       --find-object=<object-id>
516           Look for differences that change the number of occurrences of the
517           specified object. Similar to -S, just the argument is different in
518           that it doesn’t search for a specific string but for a specific
519           object id.
520
521           The object can be a blob or a submodule commit. It implies the -t
522           option in git-log to also find trees.
523
524       --pickaxe-all
525           When -S or -G finds a change, show all the changes in that
526           changeset, not just the files that contain the change in <string>.
527
528       --pickaxe-regex
529           Treat the <string> given to -S as an extended POSIX regular
530           expression to match.
531
532       -O<orderfile>
533           Control the order in which files appear in the output. This
534           overrides the diff.orderFile configuration variable (see git-
535           config(1)). To cancel diff.orderFile, use -O/dev/null.
536
537           The output order is determined by the order of glob patterns in
538           <orderfile>. All files with pathnames that match the first pattern
539           are output first, all files with pathnames that match the second
540           pattern (but not the first) are output next, and so on. All files
541           with pathnames that do not match any pattern are output last, as if
542           there was an implicit match-all pattern at the end of the file. If
543           multiple pathnames have the same rank (they match the same pattern
544           but no earlier patterns), their output order relative to each other
545           is the normal order.
546
547           <orderfile> is parsed as follows:
548
549           ·   Blank lines are ignored, so they can be used as separators for
550               readability.
551
552           ·   Lines starting with a hash ("#") are ignored, so they can be
553               used for comments. Add a backslash ("\") to the beginning of
554               the pattern if it starts with a hash.
555
556           ·   Each other line contains a single pattern.
557
558           Patterns have the same syntax and semantics as patterns used for
559           fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
560           matches a pattern if removing any number of the final pathname
561           components matches the pattern. For example, the pattern "foo*bar"
562           matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".
563
564       -R
565           Swap two inputs; that is, show differences from index or on-disk
566           file to tree contents.
567
568       --relative[=<path>]
569           When run from a subdirectory of the project, it can be told to
570           exclude changes outside the directory and show pathnames relative
571           to it with this option. When you are not in a subdirectory (e.g. in
572           a bare repository), you can name which subdirectory to make the
573           output relative to by giving a <path> as an argument.
574
575       -a, --text
576           Treat all files as text.
577
578       --ignore-cr-at-eol
579           Ignore carriage-return at the end of line when doing a comparison.
580
581       --ignore-space-at-eol
582           Ignore changes in whitespace at EOL.
583
584       -b, --ignore-space-change
585           Ignore changes in amount of whitespace. This ignores whitespace at
586           line end, and considers all other sequences of one or more
587           whitespace characters to be equivalent.
588
589       -w, --ignore-all-space
590           Ignore whitespace when comparing lines. This ignores differences
591           even if one line has whitespace where the other line has none.
592
593       --ignore-blank-lines
594           Ignore changes whose lines are all blank.
595
596       --inter-hunk-context=<lines>
597           Show the context between diff hunks, up to the specified number of
598           lines, thereby fusing hunks that are close to each other. Defaults
599           to diff.interHunkContext or 0 if the config option is unset.
600
601       -W, --function-context
602           Show whole surrounding functions of changes.
603
604       --exit-code
605           Make the program exit with codes similar to diff(1). That is, it
606           exits with 1 if there were differences and 0 means no differences.
607
608       --quiet
609           Disable all output of the program. Implies --exit-code.
610
611       --ext-diff
612           Allow an external diff helper to be executed. If you set an
613           external diff driver with gitattributes(5), you need to use this
614           option with git-log(1) and friends.
615
616       --no-ext-diff
617           Disallow external diff drivers.
618
619       --textconv, --no-textconv
620           Allow (or disallow) external text conversion filters to be run when
621           comparing binary files. See gitattributes(5) for details. Because
622           textconv filters are typically a one-way conversion, the resulting
623           diff is suitable for human consumption, but cannot be applied. For
624           this reason, textconv filters are enabled by default only for git-
625           diff(1) and git-log(1), but not for git-format-patch(1) or diff
626           plumbing commands.
627
628       --ignore-submodules[=<when>]
629           Ignore changes to submodules in the diff generation. <when> can be
630           either "none", "untracked", "dirty" or "all", which is the default.
631           Using "none" will consider the submodule modified when it either
632           contains untracked or modified files or its HEAD differs from the
633           commit recorded in the superproject and can be used to override any
634           settings of the ignore option in git-config(1) or gitmodules(5).
635           When "untracked" is used submodules are not considered dirty when
636           they only contain untracked content (but they are still scanned for
637           modified content). Using "dirty" ignores all changes to the work
638           tree of submodules, only changes to the commits stored in the
639           superproject are shown (this was the behavior until 1.7.0). Using
640           "all" hides all changes to submodules.
641
642       --src-prefix=<prefix>
643           Show the given source prefix instead of "a/".
644
645       --dst-prefix=<prefix>
646           Show the given destination prefix instead of "b/".
647
648       --no-prefix
649           Do not show any source or destination prefix.
650
651       --line-prefix=<prefix>
652           Prepend an additional prefix to every line of output.
653
654       --ita-invisible-in-index
655           By default entries added by "git add -N" appear as an existing
656           empty file in "git diff" and a new file in "git diff --cached".
657           This option makes the entry appear as a new file in "git diff" and
658           non-existent in "git diff --cached". This option could be reverted
659           with --ita-visible-in-index. Both options are experimental and
660           could be removed in future.
661
662       For more detailed explanation on these common options, see also
663       gitdiffcore(7).
664
665       <tree-ish>
666           The id of a tree object.
667
668       <path>...
669           If provided, the results are limited to a subset of files matching
670           one of the provided pathspecs.
671
672       -r
673           recurse into sub-trees
674
675       -t
676           show tree entry itself as well as subtrees. Implies -r.
677
678       --root
679           When --root is specified the initial commit will be shown as a big
680           creation event. This is equivalent to a diff against the NULL tree.
681
682       --stdin
683           When --stdin is specified, the command does not take <tree-ish>
684           arguments from the command line. Instead, it reads lines containing
685           either two <tree>, one <commit>, or a list of <commit> from its
686           standard input. (Use a single space as separator.)
687
688           When two trees are given, it compares the first tree with the
689           second. When a single commit is given, it compares the commit with
690           its parents. The remaining commits, when given, are used as if they
691           are parents of the first commit.
692
693           When comparing two trees, the ID of both trees (separated by a
694           space and terminated by a newline) is printed before the
695           difference. When comparing commits, the ID of the first (or only)
696           commit, followed by a newline, is printed.
697
698           The following flags further affect the behavior when comparing
699           commits (but not trees).
700
701       -m
702           By default, git diff-tree --stdin does not show differences for
703           merge commits. With this flag, it shows differences to that commit
704           from all of its parents. See also -c.
705
706       -s
707           By default, git diff-tree --stdin shows differences, either in
708           machine-readable form (without -p) or in patch form (with -p). This
709           output can be suppressed. It is only useful with -v flag.
710
711       -v
712           This flag causes git diff-tree --stdin to also show the commit
713           message before the differences.
714
715       --pretty[=<format>], --format=<format>
716           Pretty-print the contents of the commit logs in a given format,
717           where <format> can be one of oneline, short, medium, full, fuller,
718           reference, email, raw, format:<string> and tformat:<string>. When
719           <format> is none of the above, and has %placeholder in it, it acts
720           as if --pretty=tformat:<format> were given.
721
722           See the "PRETTY FORMATS" section for some additional details for
723           each format. When =<format> part is omitted, it defaults to medium.
724
725           Note: you can specify the default pretty format in the repository
726           configuration (see git-config(1)).
727
728       --abbrev-commit
729           Instead of showing the full 40-byte hexadecimal commit object name,
730           show only a partial prefix. Non default number of digits can be
731           specified with "--abbrev=<n>" (which also modifies diff output, if
732           it is displayed).
733
734           This should make "--pretty=oneline" a whole lot more readable for
735           people using 80-column terminals.
736
737       --no-abbrev-commit
738           Show the full 40-byte hexadecimal commit object name. This negates
739           --abbrev-commit and those options which imply it such as
740           "--oneline". It also overrides the log.abbrevCommit variable.
741
742       --oneline
743           This is a shorthand for "--pretty=oneline --abbrev-commit" used
744           together.
745
746       --encoding=<encoding>
747           The commit objects record the encoding used for the log message in
748           their encoding header; this option can be used to tell the command
749           to re-code the commit log message in the encoding preferred by the
750           user. For non plumbing commands this defaults to UTF-8. Note that
751           if an object claims to be encoded in X and we are outputting in X,
752           we will output the object verbatim; this means that invalid
753           sequences in the original commit may be copied to the output.
754
755       --expand-tabs=<n>, --expand-tabs, --no-expand-tabs
756           Perform a tab expansion (replace each tab with enough spaces to
757           fill to the next display column that is multiple of <n>) in the log
758           message before showing it in the output.  --expand-tabs is a
759           short-hand for --expand-tabs=8, and --no-expand-tabs is a
760           short-hand for --expand-tabs=0, which disables tab expansion.
761
762           By default, tabs are expanded in pretty formats that indent the log
763           message by 4 spaces (i.e.  medium, which is the default, full, and
764           fuller).
765
766       --notes[=<ref>]
767           Show the notes (see git-notes(1)) that annotate the commit, when
768           showing the commit log message. This is the default for git log,
769           git show and git whatchanged commands when there is no --pretty,
770           --format, or --oneline option given on the command line.
771
772           By default, the notes shown are from the notes refs listed in the
773           core.notesRef and notes.displayRef variables (or corresponding
774           environment overrides). See git-config(1) for more details.
775
776           With an optional <ref> argument, use the ref to find the notes to
777           display. The ref can specify the full refname when it begins with
778           refs/notes/; when it begins with notes/, refs/ and otherwise
779           refs/notes/ is prefixed to form a full name of the ref.
780
781           Multiple --notes options can be combined to control which notes are
782           being displayed. Examples: "--notes=foo" will show only notes from
783           "refs/notes/foo"; "--notes=foo --notes" will show both notes from
784           "refs/notes/foo" and from the default notes ref(s).
785
786       --no-notes
787           Do not show notes. This negates the above --notes option, by
788           resetting the list of notes refs from which notes are shown.
789           Options are parsed in the order given on the command line, so e.g.
790           "--notes --notes=foo --no-notes --notes=bar" will only show notes
791           from "refs/notes/bar".
792
793       --show-notes[=<ref>], --[no-]standard-notes
794           These options are deprecated. Use the above --notes/--no-notes
795           options instead.
796
797       --show-signature
798           Check the validity of a signed commit object by passing the
799           signature to gpg --verify and show the output.
800
801       --no-commit-id
802           git diff-tree outputs a line with the commit ID when applicable.
803           This flag suppressed the commit ID output.
804
805       -c
806           This flag changes the way a merge commit is displayed (which means
807           it is useful only when the command is given one <tree-ish>, or
808           --stdin). It shows the differences from each of the parents to the
809           merge result simultaneously instead of showing pairwise diff
810           between a parent and the result one at a time (which is what the -m
811           option does). Furthermore, it lists only files which were modified
812           from all parents.
813
814       --cc
815           This flag changes the way a merge commit patch is displayed, in a
816           similar way to the -c option. It implies the -c and -p options and
817           further compresses the patch output by omitting uninteresting hunks
818           whose the contents in the parents have only two variants and the
819           merge result picks one of them without modification. When all hunks
820           are uninteresting, the commit itself and the commit log message is
821           not shown, just like in any other "empty diff" case.
822
823       --combined-all-paths
824           This flag causes combined diffs (used for merge commits) to list
825           the name of the file from all parents. It thus only has effect when
826           -c or --cc are specified, and is likely only useful if filename
827           changes are detected (i.e. when either rename or copy detection
828           have been requested).
829
830       --always
831           Show the commit itself and the commit log message even if the diff
832           itself is empty.
833

PRETTY FORMATS

835       If the commit is a merge, and if the pretty-format is not oneline,
836       email or raw, an additional line is inserted before the Author: line.
837       This line begins with "Merge: " and the hashes of ancestral commits are
838       printed, separated by spaces. Note that the listed commits may not
839       necessarily be the list of the direct parent commits if you have
840       limited your view of history: for example, if you are only interested
841       in changes related to a certain directory or file.
842
843       There are several built-in formats, and you can define additional
844       formats by setting a pretty.<name> config option to either another
845       format name, or a format: string, as described below (see git-
846       config(1)). Here are the details of the built-in formats:
847
848       ·   oneline
849
850               <hash> <title line>
851
852           This is designed to be as compact as possible.
853
854       ·   short
855
856               commit <hash>
857               Author: <author>
858
859               <title line>
860
861       ·   medium
862
863               commit <hash>
864               Author: <author>
865               Date:   <author date>
866
867               <title line>
868
869               <full commit message>
870
871       ·   full
872
873               commit <hash>
874               Author: <author>
875               Commit: <committer>
876
877               <title line>
878
879               <full commit message>
880
881       ·   fuller
882
883               commit <hash>
884               Author:     <author>
885               AuthorDate: <author date>
886               Commit:     <committer>
887               CommitDate: <committer date>
888
889               <title line>
890
891               <full commit message>
892
893       ·   reference
894
895               <abbrev hash> (<title line>, <short author date>)
896
897           This format is used to refer to another commit in a commit message
898           and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By
899           default, the date is formatted with --date=short unless another
900           --date option is explicitly specified. As with any format: with
901           format placeholders, its output is not affected by other options
902           like --decorate and --walk-reflogs.
903
904       ·   email
905
906               From <hash> <date>
907               From: <author>
908               Date: <author date>
909               Subject: [PATCH] <title line>
910
911               <full commit message>
912
913       ·   raw
914
915           The raw format shows the entire commit exactly as stored in the
916           commit object. Notably, the hashes are displayed in full,
917           regardless of whether --abbrev or --no-abbrev are used, and parents
918           information show the true parent commits, without taking grafts or
919           history simplification into account. Note that this format affects
920           the way commits are displayed, but not the way the diff is shown
921           e.g. with git log --raw. To get full object names in a raw diff
922           format, use --no-abbrev.
923
924       ·   format:<string>
925
926           The format:<string> format allows you to specify which information
927           you want to show. It works a little bit like printf format, with
928           the notable exception that you get a newline with %n instead of \n.
929
930           E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
931           would show something like this:
932
933               The author of fe6e0ee was Junio C Hamano, 23 hours ago
934               The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
935
936           The placeholders are:
937
938           ·   Placeholders that expand to a single literal character:
939
940               %n
941                   newline
942
943               %%
944                   a raw %
945
946               %x00
947                   print a byte from a hex code
948
949           ·   Placeholders that affect formatting of later placeholders:
950
951               %Cred
952                   switch color to red
953
954               %Cgreen
955                   switch color to green
956
957               %Cblue
958                   switch color to blue
959
960               %Creset
961                   reset color
962
963               %C(...)
964                   color specification, as described under Values in the
965                   "CONFIGURATION FILE" section of git-config(1). By default,
966                   colors are shown only when enabled for log output (by
967                   color.diff, color.ui, or --color, and respecting the auto
968                   settings of the former if we are going to a terminal).
969                   %C(auto,...)  is accepted as a historical synonym for the
970                   default (e.g., %C(auto,red)). Specifying %C(always,...)
971                   will show the colors even when color is not otherwise
972                   enabled (though consider just using --color=always to
973                   enable color for the whole output, including this format
974                   and anything else git might color).  auto alone (i.e.
975                   %C(auto)) will turn on auto coloring on the next
976                   placeholders until the color is switched again.
977
978               %m
979                   left (<), right (>) or boundary (-) mark
980
981               %w([<w>[,<i1>[,<i2>]]])
982                   switch line wrapping, like the -w option of git-
983                   shortlog(1).
984
985               %<(<N>[,trunc|ltrunc|mtrunc])
986                   make the next placeholder take at least N columns, padding
987                   spaces on the right if necessary. Optionally truncate at
988                   the beginning (ltrunc), the middle (mtrunc) or the end
989                   (trunc) if the output is longer than N columns. Note that
990                   truncating only works correctly with N >= 2.
991
992               %<|(<N>)
993                   make the next placeholder take at least until Nth columns,
994                   padding spaces on the right if necessary
995
996               %>(<N>), %>|(<N>)
997                   similar to %<(<N>), %<|(<N>) respectively, but padding
998                   spaces on the left
999
1000               %>>(<N>), %>>|(<N>)
1001                   similar to %>(<N>), %>|(<N>) respectively, except that if
1002                   the next placeholder takes more spaces than given and there
1003                   are spaces on its left, use those spaces
1004
1005               %><(<N>), %><|(<N>)
1006                   similar to %<(<N>), %<|(<N>) respectively, but padding both
1007                   sides (i.e. the text is centered)
1008
1009           ·   Placeholders that expand to information extracted from the
1010               commit:
1011
1012               %H
1013                   commit hash
1014
1015               %h
1016                   abbreviated commit hash
1017
1018               %T
1019                   tree hash
1020
1021               %t
1022                   abbreviated tree hash
1023
1024               %P
1025                   parent hashes
1026
1027               %p
1028                   abbreviated parent hashes
1029
1030               %an
1031                   author name
1032
1033               %aN
1034                   author name (respecting .mailmap, see git-shortlog(1) or
1035                   git-blame(1))
1036
1037               %ae
1038                   author email
1039
1040               %aE
1041                   author email (respecting .mailmap, see git-shortlog(1) or
1042                   git-blame(1))
1043
1044               %al
1045                   author email local-part (the part before the @ sign)
1046
1047               %aL
1048                   author local-part (see %al) respecting .mailmap, see git-
1049                   shortlog(1) or git-blame(1))
1050
1051               %ad
1052                   author date (format respects --date= option)
1053
1054               %aD
1055                   author date, RFC2822 style
1056
1057               %ar
1058                   author date, relative
1059
1060               %at
1061                   author date, UNIX timestamp
1062
1063               %ai
1064                   author date, ISO 8601-like format
1065
1066               %aI
1067                   author date, strict ISO 8601 format
1068
1069               %as
1070                   author date, short format (YYYY-MM-DD)
1071
1072               %cn
1073                   committer name
1074
1075               %cN
1076                   committer name (respecting .mailmap, see git-shortlog(1) or
1077                   git-blame(1))
1078
1079               %ce
1080                   committer email
1081
1082               %cE
1083                   committer email (respecting .mailmap, see git-shortlog(1)
1084                   or git-blame(1))
1085
1086               %cl
1087                   author email local-part (the part before the @ sign)
1088
1089               %cL
1090                   author local-part (see %cl) respecting .mailmap, see git-
1091                   shortlog(1) or git-blame(1))
1092
1093               %cd
1094                   committer date (format respects --date= option)
1095
1096               %cD
1097                   committer date, RFC2822 style
1098
1099               %cr
1100                   committer date, relative
1101
1102               %ct
1103                   committer date, UNIX timestamp
1104
1105               %ci
1106                   committer date, ISO 8601-like format
1107
1108               %cI
1109                   committer date, strict ISO 8601 format
1110
1111               %cs
1112                   committer date, short format (YYYY-MM-DD)
1113
1114               %d
1115                   ref names, like the --decorate option of git-log(1)
1116
1117               %D
1118                   ref names without the " (", ")" wrapping.
1119
1120               %S
1121                   ref name given on the command line by which the commit was
1122                   reached (like git log --source), only works with git log
1123
1124               %e
1125                   encoding
1126
1127               %s
1128                   subject
1129
1130               %f
1131                   sanitized subject line, suitable for a filename
1132
1133               %b
1134                   body
1135
1136               %B
1137                   raw body (unwrapped subject and body)
1138
1139               %N
1140                   commit notes
1141
1142               %GG
1143                   raw verification message from GPG for a signed commit
1144
1145               %G?
1146                   show "G" for a good (valid) signature, "B" for a bad
1147                   signature, "U" for a good signature with unknown validity,
1148                   "X" for a good signature that has expired, "Y" for a good
1149                   signature made by an expired key, "R" for a good signature
1150                   made by a revoked key, "E" if the signature cannot be
1151                   checked (e.g. missing key) and "N" for no signature
1152
1153               %GS
1154                   show the name of the signer for a signed commit
1155
1156               %GK
1157                   show the key used to sign a signed commit
1158
1159               %GF
1160                   show the fingerprint of the key used to sign a signed
1161                   commit
1162
1163               %GP
1164                   show the fingerprint of the primary key whose subkey was
1165                   used to sign a signed commit
1166
1167               %GT
1168                   show the trust level for the key used to sign a signed
1169                   commit
1170
1171               %gD
1172                   reflog selector, e.g., refs/stash@{1} or refs/stash@{2
1173                   minutes ago}; the format follows the rules described for
1174                   the -g option. The portion before the @ is the refname as
1175                   given on the command line (so git log -g refs/heads/master
1176                   would yield refs/heads/master@{0}).
1177
1178               %gd
1179                   shortened reflog selector; same as %gD, but the refname
1180                   portion is shortened for human readability (so
1181                   refs/heads/master becomes just master).
1182
1183               %gn
1184                   reflog identity name
1185
1186               %gN
1187                   reflog identity name (respecting .mailmap, see git-
1188                   shortlog(1) or git-blame(1))
1189
1190               %ge
1191                   reflog identity email
1192
1193               %gE
1194                   reflog identity email (respecting .mailmap, see git-
1195                   shortlog(1) or git-blame(1))
1196
1197               %gs
1198                   reflog subject
1199
1200               %(trailers[:options])
1201                   display the trailers of the body as interpreted by git-
1202                   interpret-trailers(1). The trailers string may be followed
1203                   by a colon and zero or more comma-separated options:
1204
1205                   ·   key=<K>: only show trailers with specified key.
1206                       Matching is done case-insensitively and trailing colon
1207                       is optional. If option is given multiple times trailer
1208                       lines matching any of the keys are shown. This option
1209                       automatically enables the only option so that
1210                       non-trailer lines in the trailer block are hidden. If
1211                       that is not desired it can be disabled with only=false.
1212                       E.g., %(trailers:key=Reviewed-by) shows trailer lines
1213                       with key Reviewed-by.
1214
1215                   ·   only[=val]: select whether non-trailer lines from the
1216                       trailer block should be included. The only keyword may
1217                       optionally be followed by an equal sign and one of
1218                       true, on, yes to omit or false, off, no to show the
1219                       non-trailer lines. If option is given without value it
1220                       is enabled. If given multiple times the last value is
1221                       used.
1222
1223                   ·   separator=<SEP>: specify a separator inserted between
1224                       trailer lines. When this option is not given each
1225                       trailer line is terminated with a line feed character.
1226                       The string SEP may contain the literal formatting codes
1227                       described above. To use comma as separator one must use
1228                       %x2C as it would otherwise be parsed as next option. If
1229                       separator option is given multiple times only the last
1230                       one is used. E.g., %(trailers:key=Ticket,separator=%x2C
1231                       ) shows all trailer lines whose key is "Ticket"
1232                       separated by a comma and a space.
1233
1234                   ·   unfold[=val]: make it behave as if interpret-trailer’s
1235                       --unfold option was given. In same way as to for only
1236                       it can be followed by an equal sign and explicit value.
1237                       E.g., %(trailers:only,unfold=true) unfolds and shows
1238                       all trailer lines.
1239
1240                   ·   valueonly[=val]: skip over the key part of the trailer
1241                       line and only show the value part. Also this optionally
1242                       allows explicit value.
1243
1244           Note
1245           Some placeholders may depend on other options given to the revision
1246           traversal engine. For example, the %g* reflog options will insert
1247           an empty string unless we are traversing reflog entries (e.g., by
1248           git log -g). The %d and %D placeholders will use the "short"
1249           decoration format if --decorate was not already provided on the
1250           command line.
1251
1252       If you add a + (plus sign) after % of a placeholder, a line-feed is
1253       inserted immediately before the expansion if and only if the
1254       placeholder expands to a non-empty string.
1255
1256       If you add a - (minus sign) after % of a placeholder, all consecutive
1257       line-feeds immediately preceding the expansion are deleted if and only
1258       if the placeholder expands to an empty string.
1259
1260       If you add a ` ` (space) after % of a placeholder, a space is inserted
1261       immediately before the expansion if and only if the placeholder expands
1262       to a non-empty string.
1263
1264       ·   tformat:
1265
1266           The tformat: format works exactly like format:, except that it
1267           provides "terminator" semantics instead of "separator" semantics.
1268           In other words, each commit has the message terminator character
1269           (usually a newline) appended, rather than a separator placed
1270           between entries. This means that the final entry of a single-line
1271           format will be properly terminated with a new line, just as the
1272           "oneline" format does. For example:
1273
1274               $ git log -2 --pretty=format:%h 4da45bef \
1275                 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1276               4da45be
1277               7134973 -- NO NEWLINE
1278
1279               $ git log -2 --pretty=tformat:%h 4da45bef \
1280                 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1281               4da45be
1282               7134973
1283
1284           In addition, any unrecognized string that has a % in it is
1285           interpreted as if it has tformat: in front of it. For example,
1286           these two are equivalent:
1287
1288               $ git log -2 --pretty=tformat:%h 4da45bef
1289               $ git log -2 --pretty=%h 4da45bef
1290

RAW OUTPUT FORMAT

1292       The raw output format from "git-diff-index", "git-diff-tree",
1293       "git-diff-files" and "git diff --raw" are very similar.
1294
1295       These commands all compare two sets of things; what is compared
1296       differs:
1297
1298       git-diff-index <tree-ish>
1299           compares the <tree-ish> and the files on the filesystem.
1300
1301       git-diff-index --cached <tree-ish>
1302           compares the <tree-ish> and the index.
1303
1304       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
1305           compares the trees named by the two arguments.
1306
1307       git-diff-files [<pattern>...]
1308           compares the index and the files on the filesystem.
1309
1310       The "git-diff-tree" command begins its output by printing the hash of
1311       what is being compared. After that, all the commands print one output
1312       line per changed file.
1313
1314       An output line is formatted this way:
1315
1316           in-place edit  :100644 100644 bcd1234 0123456 M file0
1317           copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
1318           rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
1319           create         :000000 100644 0000000 1234567 A file4
1320           delete         :100644 000000 1234567 0000000 D file5
1321           unmerged       :000000 000000 0000000 0000000 U file6
1322
1323       That is, from the left to the right:
1324
1325        1. a colon.
1326
1327        2. mode for "src"; 000000 if creation or unmerged.
1328
1329        3. a space.
1330
1331        4. mode for "dst"; 000000 if deletion or unmerged.
1332
1333        5. a space.
1334
1335        6. sha1 for "src"; 0{40} if creation or unmerged.
1336
1337        7. a space.
1338
1339        8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1340
1341        9. a space.
1342
1343       10. status, followed by optional "score" number.
1344
1345       11. a tab or a NUL when -z option is used.
1346
1347       12. path for "src"
1348
1349       13. a tab or a NUL when -z option is used; only exists for C or R.
1350
1351       14. path for "dst"; only exists for C or R.
1352
1353       15. an LF or a NUL when -z option is used, to terminate the record.
1354
1355       Possible status letters are:
1356
1357       ·   A: addition of a file
1358
1359       ·   C: copy of a file into a new one
1360
1361       ·   D: deletion of a file
1362
1363       ·   M: modification of the contents or mode of a file
1364
1365       ·   R: renaming of a file
1366
1367       ·   T: change in the type of the file
1368
1369       ·   U: file is unmerged (you must complete the merge before it can be
1370           committed)
1371
1372       ·   X: "unknown" change type (most probably a bug, please report it)
1373
1374       Status letters C and R are always followed by a score (denoting the
1375       percentage of similarity between the source and target of the move or
1376       copy). Status letter M may be followed by a score (denoting the
1377       percentage of dissimilarity) for file rewrites.
1378
1379       <sha1> is shown as all 0’s if a file is new on the filesystem and it is
1380       out of sync with the index.
1381
1382       Example:
1383
1384           :100644 100644 5be4a4a 0000000 M file.c
1385
1386       Without the -z option, pathnames with "unusual" characters are quoted
1387       as explained for the configuration variable core.quotePath (see git-
1388       config(1)). Using -z the filename is output verbatim and the line is
1389       terminated by a NUL byte.
1390

DIFF FORMAT FOR MERGES

1392       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
1393       --cc option to generate diff output also for merge commits. The output
1394       differs from the format described above in the following way:
1395
1396        1. there is a colon for each parent
1397
1398        2. there are more "src" modes and "src" sha1
1399
1400        3. status is concatenated status characters for each parent
1401
1402        4. no optional "score" number
1403
1404        5. tab-separated pathname(s) of the file
1405
1406       For -c and --cc, only the destination or final path is shown even if
1407       the file was renamed on any side of history. With --combined-all-paths,
1408       the name of the path in each parent is shown followed by the name of
1409       the path in the merge commit.
1410
1411       Examples for -c and --cc without --combined-all-paths:
1412
1413           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c
1414           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       bar.sh
1415           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       phooey.c
1416
1417       Examples when --combined-all-paths added to either -c or --cc:
1418
1419           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c  desc.c  desc.c
1420           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       foo.sh  bar.sh  bar.sh
1421           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       fooey.c fuey.c  phooey.c
1422
1423       Note that combined diff lists only files which were modified from all
1424       parents.
1425

GENERATING PATCH TEXT WITH -P

1427       Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
1428       diff-tree(1), or git-diff-files(1) with the -p option produces patch
1429       text. You can customize the creation of patch text via the
1430       GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.
1431
1432       What the -p option produces is slightly different from the traditional
1433       diff format:
1434
1435        1. It is preceded with a "git diff" header that looks like this:
1436
1437               diff --git a/file1 b/file2
1438
1439           The a/ and b/ filenames are the same unless rename/copy is
1440           involved. Especially, even for a creation or a deletion, /dev/null
1441           is not used in place of the a/ or b/ filenames.
1442
1443           When rename/copy is involved, file1 and file2 show the name of the
1444           source file of the rename/copy and the name of the file that
1445           rename/copy produces, respectively.
1446
1447        2. It is followed by one or more extended header lines:
1448
1449               old mode <mode>
1450               new mode <mode>
1451               deleted file mode <mode>
1452               new file mode <mode>
1453               copy from <path>
1454               copy to <path>
1455               rename from <path>
1456               rename to <path>
1457               similarity index <number>
1458               dissimilarity index <number>
1459               index <hash>..<hash> <mode>
1460
1461           File modes are printed as 6-digit octal numbers including the file
1462           type and file permission bits.
1463
1464           Path names in extended headers do not include the a/ and b/
1465           prefixes.
1466
1467           The similarity index is the percentage of unchanged lines, and the
1468           dissimilarity index is the percentage of changed lines. It is a
1469           rounded down integer, followed by a percent sign. The similarity
1470           index value of 100% is thus reserved for two equal files, while
1471           100% dissimilarity means that no line from the old file made it
1472           into the new one.
1473
1474           The index line includes the blob object names before and after the
1475           change. The <mode> is included if the file mode does not change;
1476           otherwise, separate lines indicate the old and the new mode.
1477
1478        3. Pathnames with "unusual" characters are quoted as explained for the
1479           configuration variable core.quotePath (see git-config(1)).
1480
1481        4. All the file1 files in the output refer to files before the commit,
1482           and all the file2 files refer to files after the commit. It is
1483           incorrect to apply each change to each file sequentially. For
1484           example, this patch will swap a and b:
1485
1486               diff --git a/a b/b
1487               rename from a
1488               rename to b
1489               diff --git a/b b/a
1490               rename from b
1491               rename to a
1492

COMBINED DIFF FORMAT

1494       Any diff-generating command can take the -c or --cc option to produce a
1495       combined diff when showing a merge. This is the default format when
1496       showing merges with git-diff(1) or git-show(1). Note also that you can
1497       give the -m option to any of these commands to force generation of
1498       diffs with individual parents of a merge.
1499
1500       A "combined diff" format looks like this:
1501
1502           diff --combined describe.c
1503           index fabadb8,cc95eb0..4866510
1504           --- a/describe.c
1505           +++ b/describe.c
1506           @@@ -98,20 -98,12 +98,20 @@@
1507                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1508             }
1509
1510           - static void describe(char *arg)
1511            -static void describe(struct commit *cmit, int last_one)
1512           ++static void describe(char *arg, int last_one)
1513             {
1514            +      unsigned char sha1[20];
1515            +      struct commit *cmit;
1516                   struct commit_list *list;
1517                   static int initialized = 0;
1518                   struct commit_name *n;
1519
1520            +      if (get_sha1(arg, sha1) < 0)
1521            +              usage(describe_usage);
1522            +      cmit = lookup_commit_reference(sha1);
1523            +      if (!cmit)
1524            +              usage(describe_usage);
1525            +
1526                   if (!initialized) {
1527                           initialized = 1;
1528                           for_each_ref(get_name);
1529
1530        1. It is preceded with a "git diff" header, that looks like this (when
1531           the -c option is used):
1532
1533               diff --combined file
1534
1535           or like this (when the --cc option is used):
1536
1537               diff --cc file
1538
1539        2. It is followed by one or more extended header lines (this example
1540           shows a merge with two parents):
1541
1542               index <hash>,<hash>..<hash>
1543               mode <mode>,<mode>..<mode>
1544               new file mode <mode>
1545               deleted file mode <mode>,<mode>
1546
1547           The mode <mode>,<mode>..<mode> line appears only if at least one of
1548           the <mode> is different from the rest. Extended headers with
1549           information about detected contents movement (renames and copying
1550           detection) are designed to work with diff of two <tree-ish> and are
1551           not used by combined diff format.
1552
1553        3. It is followed by two-line from-file/to-file header
1554
1555               --- a/file
1556               +++ b/file
1557
1558           Similar to two-line header for traditional unified diff format,
1559           /dev/null is used to signal created or deleted files.
1560
1561           However, if the --combined-all-paths option is provided, instead of
1562           a two-line from-file/to-file you get a N+1 line from-file/to-file
1563           header, where N is the number of parents in the merge commit
1564
1565               --- a/file
1566               --- a/file
1567               --- a/file
1568               +++ b/file
1569
1570           This extended format can be useful if rename or copy detection is
1571           active, to allow you to see the original name of the file in
1572           different parents.
1573
1574        4. Chunk header format is modified to prevent people from accidentally
1575           feeding it to patch -p1. Combined diff format was created for
1576           review of merge commit changes, and was not meant to be applied.
1577           The change is similar to the change in the extended index header:
1578
1579               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
1580
1581           There are (number of parents + 1) @ characters in the chunk header
1582           for combined diff format.
1583
1584       Unlike the traditional unified diff format, which shows two files A and
1585       B with a single column that has - (minus — appears in A but removed in
1586       B), + (plus — missing in A but added to B), or " " (space — unchanged)
1587       prefix, this format compares two or more files file1, file2,... with
1588       one file X, and shows how X differs from each of fileN. One column for
1589       each of fileN is prepended to the output line to note how X’s line is
1590       different from it.
1591
1592       A - character in the column N means that the line appears in fileN but
1593       it does not appear in the result. A + character in the column N means
1594       that the line appears in the result, and fileN does not have that line
1595       (in other words, the line was added, from the point of view of that
1596       parent).
1597
1598       In the above example output, the function signature was changed from
1599       both files (hence two - removals from both file1 and file2, plus ++ to
1600       mean one line that was added does not appear in either file1 or file2).
1601       Also eight other lines are the same from file1 but do not appear in
1602       file2 (hence prefixed with +).
1603
1604       When shown by git diff-tree -c, it compares the parents of a merge
1605       commit with the merge result (i.e. file1..fileN are the parents). When
1606       shown by git diff-files -c, it compares the two unresolved merge
1607       parents with the working tree file (i.e. file1 is stage 2 aka "our
1608       version", file2 is stage 3 aka "their version").
1609

OTHER DIFF FORMATS

1611       The --summary option describes newly added, deleted, renamed and copied
1612       files. The --stat option adds diffstat(1) graph to the output. These
1613       options can be combined with other options, such as -p, and are meant
1614       for human consumption.
1615
1616       When showing a change that involves a rename or a copy, --stat output
1617       formats the pathnames compactly by combining common prefix and suffix
1618       of the pathnames. For example, a change that moves arch/i386/Makefile
1619       to arch/x86/Makefile while modifying 4 lines will be shown like this:
1620
1621           arch/{i386 => x86}/Makefile    |   4 +--
1622
1623       The --numstat option gives the diffstat(1) information but is designed
1624       for easier machine consumption. An entry in --numstat output looks like
1625       this:
1626
1627           1       2       README
1628           3       1       arch/{i386 => x86}/Makefile
1629
1630       That is, from left to right:
1631
1632        1. the number of added lines;
1633
1634        2. a tab;
1635
1636        3. the number of deleted lines;
1637
1638        4. a tab;
1639
1640        5. pathname (possibly with rename/copy information);
1641
1642        6. a newline.
1643
1644       When -z output option is in effect, the output is formatted this way:
1645
1646           1       2       README NUL
1647           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
1648
1649       That is:
1650
1651        1. the number of added lines;
1652
1653        2. a tab;
1654
1655        3. the number of deleted lines;
1656
1657        4. a tab;
1658
1659        5. a NUL (only exists if renamed/copied);
1660
1661        6. pathname in preimage;
1662
1663        7. a NUL (only exists if renamed/copied);
1664
1665        8. pathname in postimage (only exists if renamed/copied);
1666
1667        9. a NUL.
1668
1669       The extra NUL before the preimage path in renamed case is to allow
1670       scripts that read the output to tell if the current record being read
1671       is a single-path record or a rename/copy record without reading ahead.
1672       After reading added and deleted lines, reading up to NUL would yield
1673       the pathname, but if that is NUL, the record will show two paths.
1674

GIT

1676       Part of the git(1) suite
1677
1678
1679
1680Git 2.26.2                        2020-04-20                  GIT-DIFF-TREE(1)
Impressum