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] [--merge-base]
12                     [<common-diff-options>] <tree-ish> [<tree-ish>] [<path>...]
13

DESCRIPTION

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

PRETTY FORMATS

881       If the commit is a merge, and if the pretty-format is not oneline,
882       email or raw, an additional line is inserted before the Author: line.
883       This line begins with "Merge: " and the hashes of ancestral commits are
884       printed, separated by spaces. Note that the listed commits may not
885       necessarily be the list of the direct parent commits if you have
886       limited your view of history: for example, if you are only interested
887       in changes related to a certain directory or file.
888
889       There are several built-in formats, and you can define additional
890       formats by setting a pretty.<name> config option to either another
891       format name, or a format: string, as described below (see git-
892       config(1)). Here are the details of the built-in formats:
893
894oneline
895
896               <hash> <title-line>
897
898           This is designed to be as compact as possible.
899
900short
901
902               commit <hash>
903               Author: <author>
904
905               <title-line>
906
907medium
908
909               commit <hash>
910               Author: <author>
911               Date:   <author-date>
912
913               <title-line>
914
915               <full-commit-message>
916
917full
918
919               commit <hash>
920               Author: <author>
921               Commit: <committer>
922
923               <title-line>
924
925               <full-commit-message>
926
927fuller
928
929               commit <hash>
930               Author:     <author>
931               AuthorDate: <author-date>
932               Commit:     <committer>
933               CommitDate: <committer-date>
934
935               <title-line>
936
937               <full-commit-message>
938
939reference
940
941               <abbrev-hash> (<title-line>, <short-author-date>)
942
943           This format is used to refer to another commit in a commit message
944           and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By
945           default, the date is formatted with --date=short unless another
946           --date option is explicitly specified. As with any format: with
947           format placeholders, its output is not affected by other options
948           like --decorate and --walk-reflogs.
949
950email
951
952               From <hash> <date>
953               From: <author>
954               Date: <author-date>
955               Subject: [PATCH] <title-line>
956
957               <full-commit-message>
958
959mboxrd
960
961           Like email, but lines in the commit message starting with "From "
962           (preceded by zero or more ">") are quoted with ">" so they aren’t
963           confused as starting a new commit.
964
965raw
966
967           The raw format shows the entire commit exactly as stored in the
968           commit object. Notably, the hashes are displayed in full,
969           regardless of whether --abbrev or --no-abbrev are used, and parents
970           information show the true parent commits, without taking grafts or
971           history simplification into account. Note that this format affects
972           the way commits are displayed, but not the way the diff is shown
973           e.g. with git log --raw. To get full object names in a raw diff
974           format, use --no-abbrev.
975
976format:<format-string>
977
978           The format:<format-string> format allows you to specify which
979           information you want to show. It works a little bit like printf
980           format, with the notable exception that you get a newline with %n
981           instead of \n.
982
983           E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
984           would show something like this:
985
986               The author of fe6e0ee was Junio C Hamano, 23 hours ago
987               The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
988
989           The placeholders are:
990
991           •   Placeholders that expand to a single literal character:
992
993               %n
994                   newline
995
996               %%
997                   a raw %
998
999               %x00
1000                   %x followed by two hexadecimal digits is replaced with a
1001                   byte with the hexadecimal digits' value (we will call this
1002                   "literal formatting code" in the rest of this document).
1003
1004           •   Placeholders that affect formatting of later placeholders:
1005
1006               %Cred
1007                   switch color to red
1008
1009               %Cgreen
1010                   switch color to green
1011
1012               %Cblue
1013                   switch color to blue
1014
1015               %Creset
1016                   reset color
1017
1018               %C(...)
1019                   color specification, as described under Values in the
1020                   "CONFIGURATION FILE" section of git-config(1). By default,
1021                   colors are shown only when enabled for log output (by
1022                   color.diff, color.ui, or --color, and respecting the auto
1023                   settings of the former if we are going to a terminal).
1024                   %C(auto,...)  is accepted as a historical synonym for the
1025                   default (e.g., %C(auto,red)). Specifying %C(always,...)
1026                   will show the colors even when color is not otherwise
1027                   enabled (though consider just using --color=always to
1028                   enable color for the whole output, including this format
1029                   and anything else git might color).  auto alone (i.e.
1030                   %C(auto)) will turn on auto coloring on the next
1031                   placeholders until the color is switched again.
1032
1033               %m
1034                   left (<), right (>) or boundary (-) mark
1035
1036               %w([<w>[,<i1>[,<i2>]]])
1037                   switch line wrapping, like the -w option of git-
1038                   shortlog(1).
1039
1040               %<( <N> [,trunc|ltrunc|mtrunc])
1041                   make the next placeholder take at least N column widths,
1042                   padding spaces on the right if necessary. Optionally
1043                   truncate (with ellipsis ..) at the left (ltrunc) ..ft, the
1044                   middle (mtrunc) mi..le, or the end (trunc) rig.., if the
1045                   output is longer than N columns. Note 1: that truncating
1046                   only works correctly with N >= 2. Note 2: spaces around the
1047                   N and M (see below) values are optional. Note 3: Emojis and
1048                   other wide characters will take two display columns, which
1049                   may over-run column boundaries. Note 4: decomposed
1050                   character combining marks may be misplaced at padding
1051                   boundaries.
1052
1053               %<|( <M> )
1054                   make the next placeholder take at least until Mth display
1055                   column, padding spaces on the right if necessary. Use
1056                   negative M values for column positions measured from the
1057                   right hand edge of the terminal window.
1058
1059               %>( <N> ), %>|( <M> )
1060                   similar to %<( <N> ), %<|( <M> ) respectively, but padding
1061                   spaces on the left
1062
1063               %>>( <N> ), %>>|( <M> )
1064                   similar to %>( <N> ), %>|( <M> ) respectively, except that
1065                   if the next placeholder takes more spaces than given and
1066                   there are spaces on its left, use those spaces
1067
1068               %><( <N> ), %><|( <M> )
1069                   similar to %<( <N> ), %<|( <M> ) respectively, but padding
1070                   both sides (i.e. the text is centered)
1071
1072           •   Placeholders that expand to information extracted from the
1073               commit:
1074
1075               %H
1076                   commit hash
1077
1078               %h
1079                   abbreviated commit hash
1080
1081               %T
1082                   tree hash
1083
1084               %t
1085                   abbreviated tree hash
1086
1087               %P
1088                   parent hashes
1089
1090               %p
1091                   abbreviated parent hashes
1092
1093               %an
1094                   author name
1095
1096               %aN
1097                   author name (respecting .mailmap, see git-shortlog(1) or
1098                   git-blame(1))
1099
1100               %ae
1101                   author email
1102
1103               %aE
1104                   author email (respecting .mailmap, see git-shortlog(1) or
1105                   git-blame(1))
1106
1107               %al
1108                   author email local-part (the part before the @ sign)
1109
1110               %aL
1111                   author local-part (see %al) respecting .mailmap, see git-
1112                   shortlog(1) or git-blame(1))
1113
1114               %ad
1115                   author date (format respects --date= option)
1116
1117               %aD
1118                   author date, RFC2822 style
1119
1120               %ar
1121                   author date, relative
1122
1123               %at
1124                   author date, UNIX timestamp
1125
1126               %ai
1127                   author date, ISO 8601-like format
1128
1129               %aI
1130                   author date, strict ISO 8601 format
1131
1132               %as
1133                   author date, short format (YYYY-MM-DD)
1134
1135               %ah
1136                   author date, human style (like the --date=human option of
1137                   git-rev-list(1))
1138
1139               %cn
1140                   committer name
1141
1142               %cN
1143                   committer name (respecting .mailmap, see git-shortlog(1) or
1144                   git-blame(1))
1145
1146               %ce
1147                   committer email
1148
1149               %cE
1150                   committer email (respecting .mailmap, see git-shortlog(1)
1151                   or git-blame(1))
1152
1153               %cl
1154                   committer email local-part (the part before the @ sign)
1155
1156               %cL
1157                   committer local-part (see %cl) respecting .mailmap, see
1158                   git-shortlog(1) or git-blame(1))
1159
1160               %cd
1161                   committer date (format respects --date= option)
1162
1163               %cD
1164                   committer date, RFC2822 style
1165
1166               %cr
1167                   committer date, relative
1168
1169               %ct
1170                   committer date, UNIX timestamp
1171
1172               %ci
1173                   committer date, ISO 8601-like format
1174
1175               %cI
1176                   committer date, strict ISO 8601 format
1177
1178               %cs
1179                   committer date, short format (YYYY-MM-DD)
1180
1181               %ch
1182                   committer date, human style (like the --date=human option
1183                   of git-rev-list(1))
1184
1185               %d
1186                   ref names, like the --decorate option of git-log(1)
1187
1188               %D
1189                   ref names without the " (", ")" wrapping.
1190
1191               %(decorate[:<options>])
1192                   ref names with custom decorations. The decorate string may
1193                   be followed by a colon and zero or more comma-separated
1194                   options. Option values may contain literal formatting
1195                   codes. These must be used for commas (%x2C) and closing
1196                   parentheses (%x29), due to their role in the option syntax.
1197
1198prefix=<value>: Shown before the list of ref names.
1199                       Defaults to " (".
1200
1201suffix=<value>: Shown after the list of ref names.
1202                       Defaults to ")".
1203
1204separator=<value>: Shown between ref names. Defaults to
1205                       ", ".
1206
1207pointer=<value>: Shown between HEAD and the branch it
1208                       points to, if any. Defaults to " -> ".
1209
1210tag=<value>: Shown before tag names. Defaults to
1211                       "tag: ".
1212
1213           For example, to produce decorations with no wrapping or tag
1214           annotations, and spaces as separators:
1215
1216           + %(decorate:prefix=,suffix=,tag=,separator= )
1217
1218           %(describe[:<options>])
1219               human-readable name, like git-describe(1); empty string for
1220               undescribable commits. The describe string may be followed by a
1221               colon and zero or more comma-separated options. Descriptions
1222               can be inconsistent when tags are added or removed at the same
1223               time.
1224
1225tags[=<bool-value>]: Instead of only considering annotated
1226                   tags, consider lightweight tags as well.
1227
1228abbrev=<number>: Instead of using the default number of
1229                   hexadecimal digits (which will vary according to the number
1230                   of objects in the repository with a default of 7) of the
1231                   abbreviated object name, use <number> digits, or as many
1232                   digits as needed to form a unique object name.
1233
1234match=<pattern>: Only consider tags matching the given
1235                   glob(7) pattern, excluding the "refs/tags/" prefix.
1236
1237exclude=<pattern>: Do not consider tags matching the given
1238                   glob(7) pattern, excluding the "refs/tags/" prefix.
1239
1240           %S
1241               ref name given on the command line by which the commit was
1242               reached (like git log --source), only works with git log
1243
1244           %e
1245               encoding
1246
1247           %s
1248               subject
1249
1250           %f
1251               sanitized subject line, suitable for a filename
1252
1253           %b
1254               body
1255
1256           %B
1257               raw body (unwrapped subject and body)
1258
1259           %N
1260               commit notes
1261
1262           %GG
1263               raw verification message from GPG for a signed commit
1264
1265           %G?
1266               show "G" for a good (valid) signature, "B" for a bad signature,
1267               "U" for a good signature with unknown validity, "X" for a good
1268               signature that has expired, "Y" for a good signature made by an
1269               expired key, "R" for a good signature made by a revoked key,
1270               "E" if the signature cannot be checked (e.g. missing key) and
1271               "N" for no signature
1272
1273           %GS
1274               show the name of the signer for a signed commit
1275
1276           %GK
1277               show the key used to sign a signed commit
1278
1279           %GF
1280               show the fingerprint of the key used to sign a signed commit
1281
1282           %GP
1283               show the fingerprint of the primary key whose subkey was used
1284               to sign a signed commit
1285
1286           %GT
1287               show the trust level for the key used to sign a signed commit
1288
1289           %gD
1290               reflog selector, e.g., refs/stash@{1} or refs/stash@{2 minutes
1291               ago}; the format follows the rules described for the -g option.
1292               The portion before the @ is the refname as given on the command
1293               line (so git log -g refs/heads/master would yield
1294               refs/heads/master@{0}).
1295
1296           %gd
1297               shortened reflog selector; same as %gD, but the refname portion
1298               is shortened for human readability (so refs/heads/master
1299               becomes just master).
1300
1301           %gn
1302               reflog identity name
1303
1304           %gN
1305               reflog identity name (respecting .mailmap, see git-shortlog(1)
1306               or git-blame(1))
1307
1308           %ge
1309               reflog identity email
1310
1311           %gE
1312               reflog identity email (respecting .mailmap, see git-shortlog(1)
1313               or git-blame(1))
1314
1315           %gs
1316               reflog subject
1317
1318           %(trailers[:<options>])
1319               display the trailers of the body as interpreted by git-
1320               interpret-trailers(1). The trailers string may be followed by a
1321               colon and zero or more comma-separated options. If any option
1322               is provided multiple times, the last occurrence wins.
1323
1324key=<key>: only show trailers with specified <key>.
1325                   Matching is done case-insensitively and trailing colon is
1326                   optional. If option is given multiple times trailer lines
1327                   matching any of the keys are shown. This option
1328                   automatically enables the only option so that non-trailer
1329                   lines in the trailer block are hidden. If that is not
1330                   desired it can be disabled with only=false. E.g.,
1331                   %(trailers:key=Reviewed-by) shows trailer lines with key
1332                   Reviewed-by.
1333
1334only[=<bool>]: select whether non-trailer lines from the
1335                   trailer block should be included.
1336
1337separator=<sep>: specify a separator inserted between
1338                   trailer lines. When this option is not given each trailer
1339                   line is terminated with a line feed character. The string
1340                   <sep> may contain the literal formatting codes described
1341                   above. To use comma as separator one must use %x2C as it
1342                   would otherwise be parsed as next option. E.g.,
1343                   %(trailers:key=Ticket,separator=%x2C ) shows all trailer
1344                   lines whose key is "Ticket" separated by a comma and a
1345                   space.
1346
1347unfold[=<bool>]: make it behave as if interpret-trailer’s
1348                   --unfold option was given. E.g.,
1349                   %(trailers:only,unfold=true) unfolds and shows all trailer
1350                   lines.
1351
1352keyonly[=<bool>]: only show the key part of the trailer.
1353
1354valueonly[=<bool>]: only show the value part of the
1355                   trailer.
1356
1357key_value_separator=<sep>: specify a separator inserted
1358                   between trailer lines. When this option is not given each
1359                   trailer key-value pair is separated by ": ". Otherwise it
1360                   shares the same semantics as separator=<sep> above.
1361
1362           Note
1363           Some placeholders may depend on other options given to the revision
1364           traversal engine. For example, the %g* reflog options will insert
1365           an empty string unless we are traversing reflog entries (e.g., by
1366           git log -g). The %d and %D placeholders will use the "short"
1367           decoration format if --decorate was not already provided on the
1368           command line.
1369
1370       The boolean options accept an optional value [=<bool-value>]. The
1371       values true, false, on, off etc. are all accepted. See the "boolean"
1372       sub-section in "EXAMPLES" in git-config(1). If a boolean option is
1373       given with no value, it’s enabled.
1374
1375       If you add a + (plus sign) after % of a placeholder, a line-feed is
1376       inserted immediately before the expansion if and only if the
1377       placeholder expands to a non-empty string.
1378
1379       If you add a - (minus sign) after % of a placeholder, all consecutive
1380       line-feeds immediately preceding the expansion are deleted if and only
1381       if the placeholder expands to an empty string.
1382
1383       If you add a ` ` (space) after % of a placeholder, a space is inserted
1384       immediately before the expansion if and only if the placeholder expands
1385       to a non-empty string.
1386
1387tformat:
1388
1389           The tformat: format works exactly like format:, except that it
1390           provides "terminator" semantics instead of "separator" semantics.
1391           In other words, each commit has the message terminator character
1392           (usually a newline) appended, rather than a separator placed
1393           between entries. This means that the final entry of a single-line
1394           format will be properly terminated with a new line, just as the
1395           "oneline" format does. For example:
1396
1397               $ git log -2 --pretty=format:%h 4da45bef \
1398                 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1399               4da45be
1400               7134973 -- NO NEWLINE
1401
1402               $ git log -2 --pretty=tformat:%h 4da45bef \
1403                 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1404               4da45be
1405               7134973
1406
1407           In addition, any unrecognized string that has a % in it is
1408           interpreted as if it has tformat: in front of it. For example,
1409           these two are equivalent:
1410
1411               $ git log -2 --pretty=tformat:%h 4da45bef
1412               $ git log -2 --pretty=%h 4da45bef
1413

RAW OUTPUT FORMAT

1415       The raw output format from "git-diff-index", "git-diff-tree",
1416       "git-diff-files" and "git diff --raw" are very similar.
1417
1418       These commands all compare two sets of things; what is compared
1419       differs:
1420
1421       git-diff-index <tree-ish>
1422           compares the <tree-ish> and the files on the filesystem.
1423
1424       git-diff-index --cached <tree-ish>
1425           compares the <tree-ish> and the index.
1426
1427       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
1428           compares the trees named by the two arguments.
1429
1430       git-diff-files [<pattern>...]
1431           compares the index and the files on the filesystem.
1432
1433       The "git-diff-tree" command begins its output by printing the hash of
1434       what is being compared. After that, all the commands print one output
1435       line per changed file.
1436
1437       An output line is formatted this way:
1438
1439           in-place edit  :100644 100644 bcd1234 0123456 M file0
1440           copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
1441           rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
1442           create         :000000 100644 0000000 1234567 A file4
1443           delete         :100644 000000 1234567 0000000 D file5
1444           unmerged       :000000 000000 0000000 0000000 U file6
1445
1446       That is, from the left to the right:
1447
1448        1. a colon.
1449
1450        2. mode for "src"; 000000 if creation or unmerged.
1451
1452        3. a space.
1453
1454        4. mode for "dst"; 000000 if deletion or unmerged.
1455
1456        5. a space.
1457
1458        6. sha1 for "src"; 0{40} if creation or unmerged.
1459
1460        7. a space.
1461
1462        8. sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of
1463           sync with the index".
1464
1465        9. a space.
1466
1467       10. status, followed by optional "score" number.
1468
1469       11. a tab or a NUL when -z option is used.
1470
1471       12. path for "src"
1472
1473       13. a tab or a NUL when -z option is used; only exists for C or R.
1474
1475       14. path for "dst"; only exists for C or R.
1476
1477       15. an LF or a NUL when -z option is used, to terminate the record.
1478
1479       Possible status letters are:
1480
1481       •   A: addition of a file
1482
1483       •   C: copy of a file into a new one
1484
1485       •   D: deletion of a file
1486
1487       •   M: modification of the contents or mode of a file
1488
1489       •   R: renaming of a file
1490
1491       •   T: change in the type of the file (regular file, symbolic link or
1492           submodule)
1493
1494       •   U: file is unmerged (you must complete the merge before it can be
1495           committed)
1496
1497       •   X: "unknown" change type (most probably a bug, please report it)
1498
1499       Status letters C and R are always followed by a score (denoting the
1500       percentage of similarity between the source and target of the move or
1501       copy). Status letter M may be followed by a score (denoting the
1502       percentage of dissimilarity) for file rewrites.
1503
1504       The sha1 for "dst" is shown as all 0’s if a file on the filesystem is
1505       out of sync with the index.
1506
1507       Example:
1508
1509           :100644 100644 5be4a4a 0000000 M file.c
1510
1511       Without the -z option, pathnames with "unusual" characters are quoted
1512       as explained for the configuration variable core.quotePath (see git-
1513       config(1)). Using -z the filename is output verbatim and the line is
1514       terminated by a NUL byte.
1515

DIFF FORMAT FOR MERGES

1517       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
1518       --cc option to generate diff output also for merge commits. The output
1519       differs from the format described above in the following way:
1520
1521        1. there is a colon for each parent
1522
1523        2. there are more "src" modes and "src" sha1
1524
1525        3. status is concatenated status characters for each parent
1526
1527        4. no optional "score" number
1528
1529        5. tab-separated pathname(s) of the file
1530
1531       For -c and --cc, only the destination or final path is shown even if
1532       the file was renamed on any side of history. With --combined-all-paths,
1533       the name of the path in each parent is shown followed by the name of
1534       the path in the merge commit.
1535
1536       Examples for -c and --cc without --combined-all-paths:
1537
1538           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c
1539           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       bar.sh
1540           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       phooey.c
1541
1542       Examples when --combined-all-paths added to either -c or --cc:
1543
1544           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c  desc.c  desc.c
1545           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       foo.sh  bar.sh  bar.sh
1546           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       fooey.c fuey.c  phooey.c
1547
1548       Note that combined diff lists only files which were modified from all
1549       parents.
1550

GENERATING PATCH TEXT WITH -P

1552       Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
1553       diff-tree(1), or git-diff-files(1) with the -p option produces patch
1554       text. You can customize the creation of patch text via the
1555       GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables (see
1556       git(1)), and the diff attribute (see gitattributes(5)).
1557
1558       What the -p option produces is slightly different from the traditional
1559       diff format:
1560
1561        1. It is preceded by a "git diff" header that looks like this:
1562
1563               diff --git a/file1 b/file2
1564
1565           The a/ and b/ filenames are the same unless rename/copy is
1566           involved. Especially, even for a creation or a deletion, /dev/null
1567           is not used in place of the a/ or b/ filenames.
1568
1569           When a rename/copy is involved, file1 and file2 show the name of
1570           the source file of the rename/copy and the name of the file that
1571           the rename/copy produces, respectively.
1572
1573        2. It is followed by one or more extended header lines:
1574
1575               old mode <mode>
1576               new mode <mode>
1577               deleted file mode <mode>
1578               new file mode <mode>
1579               copy from <path>
1580               copy to <path>
1581               rename from <path>
1582               rename to <path>
1583               similarity index <number>
1584               dissimilarity index <number>
1585               index <hash>..<hash> <mode>
1586
1587           File modes are printed as 6-digit octal numbers including the file
1588           type and file permission bits.
1589
1590           Path names in extended headers do not include the a/ and b/
1591           prefixes.
1592
1593           The similarity index is the percentage of unchanged lines, and the
1594           dissimilarity index is the percentage of changed lines. It is a
1595           rounded down integer, followed by a percent sign. The similarity
1596           index value of 100% is thus reserved for two equal files, while
1597           100% dissimilarity means that no line from the old file made it
1598           into the new one.
1599
1600           The index line includes the blob object names before and after the
1601           change. The <mode> is included if the file mode does not change;
1602           otherwise, separate lines indicate the old and the new mode.
1603
1604        3. Pathnames with "unusual" characters are quoted as explained for the
1605           configuration variable core.quotePath (see git-config(1)).
1606
1607        4. All the file1 files in the output refer to files before the commit,
1608           and all the file2 files refer to files after the commit. It is
1609           incorrect to apply each change to each file sequentially. For
1610           example, this patch will swap a and b:
1611
1612               diff --git a/a b/b
1613               rename from a
1614               rename to b
1615               diff --git a/b b/a
1616               rename from b
1617               rename to a
1618
1619        5. Hunk headers mention the name of the function to which the hunk
1620           applies. See "Defining a custom hunk-header" in gitattributes(5)
1621           for details of how to tailor this to specific languages.
1622

COMBINED DIFF FORMAT

1624       Any diff-generating command can take the -c or --cc option to produce a
1625       combined diff when showing a merge. This is the default format when
1626       showing merges with git-diff(1) or git-show(1). Note also that you can
1627       give suitable --diff-merges option to any of these commands to force
1628       generation of diffs in a specific format.
1629
1630       A "combined diff" format looks like this:
1631
1632           diff --combined describe.c
1633           index fabadb8,cc95eb0..4866510
1634           --- a/describe.c
1635           +++ b/describe.c
1636           @@@ -98,20 -98,12 +98,20 @@@
1637                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1638             }
1639
1640           - static void describe(char *arg)
1641            -static void describe(struct commit *cmit, int last_one)
1642           ++static void describe(char *arg, int last_one)
1643             {
1644            +      unsigned char sha1[20];
1645            +      struct commit *cmit;
1646                   struct commit_list *list;
1647                   static int initialized = 0;
1648                   struct commit_name *n;
1649
1650            +      if (get_sha1(arg, sha1) < 0)
1651            +              usage(describe_usage);
1652            +      cmit = lookup_commit_reference(sha1);
1653            +      if (!cmit)
1654            +              usage(describe_usage);
1655            +
1656                   if (!initialized) {
1657                           initialized = 1;
1658                           for_each_ref(get_name);
1659
1660        1. It is preceded by a "git diff" header, that looks like this (when
1661           the -c option is used):
1662
1663               diff --combined file
1664
1665           or like this (when the --cc option is used):
1666
1667               diff --cc file
1668
1669        2. It is followed by one or more extended header lines (this example
1670           shows a merge with two parents):
1671
1672               index <hash>,<hash>..<hash>
1673               mode <mode>,<mode>..<mode>
1674               new file mode <mode>
1675               deleted file mode <mode>,<mode>
1676
1677           The mode <mode>,<mode>..<mode> line appears only if at least one of
1678           the <mode> is different from the rest. Extended headers with
1679           information about detected content movement (renames and copying
1680           detection) are designed to work with the diff of two <tree-ish> and
1681           are not used by combined diff format.
1682
1683        3. It is followed by a two-line from-file/to-file header:
1684
1685               --- a/file
1686               +++ b/file
1687
1688           Similar to the two-line header for the traditional unified diff
1689           format, /dev/null is used to signal created or deleted files.
1690
1691           However, if the --combined-all-paths option is provided, instead of
1692           a two-line from-file/to-file, you get an N+1 line from-file/to-file
1693           header, where N is the number of parents in the merge commit:
1694
1695               --- a/file
1696               --- a/file
1697               --- a/file
1698               +++ b/file
1699
1700           This extended format can be useful if rename or copy detection is
1701           active, to allow you to see the original name of the file in
1702           different parents.
1703
1704        4. Chunk header format is modified to prevent people from accidentally
1705           feeding it to patch -p1. Combined diff format was created for
1706           review of merge commit changes, and was not meant to be applied.
1707           The change is similar to the change in the extended index header:
1708
1709               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
1710
1711           There are (number of parents + 1) @ characters in the chunk header
1712           for combined diff format.
1713
1714       Unlike the traditional unified diff format, which shows two files A and
1715       B with a single column that has - (minus — appears in A but removed in
1716       B), + (plus — missing in A but added to B), or " " (space — unchanged)
1717       prefix, this format compares two or more files file1, file2,... with
1718       one file X, and shows how X differs from each of fileN. One column for
1719       each of fileN is prepended to the output line to note how X’s line is
1720       different from it.
1721
1722       A - character in the column N means that the line appears in fileN but
1723       it does not appear in the result. A + character in the column N means
1724       that the line appears in the result, and fileN does not have that line
1725       (in other words, the line was added, from the point of view of that
1726       parent).
1727
1728       In the above example output, the function signature was changed from
1729       both files (hence two - removals from both file1 and file2, plus ++ to
1730       mean one line that was added does not appear in either file1 or file2).
1731       Also, eight other lines are the same from file1 but do not appear in
1732       file2 (hence prefixed with +).
1733
1734       When shown by git diff-tree -c, it compares the parents of a merge
1735       commit with the merge result (i.e. file1..fileN are the parents). When
1736       shown by git diff-files -c, it compares the two unresolved merge
1737       parents with the working tree file (i.e. file1 is stage 2 aka "our
1738       version", file2 is stage 3 aka "their version").
1739

OTHER DIFF FORMATS

1741       The --summary option describes newly added, deleted, renamed and copied
1742       files. The --stat option adds diffstat(1) graph to the output. These
1743       options can be combined with other options, such as -p, and are meant
1744       for human consumption.
1745
1746       When showing a change that involves a rename or a copy, --stat output
1747       formats the pathnames compactly by combining common prefix and suffix
1748       of the pathnames. For example, a change that moves arch/i386/Makefile
1749       to arch/x86/Makefile while modifying 4 lines will be shown like this:
1750
1751           arch/{i386 => x86}/Makefile    |   4 +--
1752
1753       The --numstat option gives the diffstat(1) information but is designed
1754       for easier machine consumption. An entry in --numstat output looks like
1755       this:
1756
1757           1       2       README
1758           3       1       arch/{i386 => x86}/Makefile
1759
1760       That is, from left to right:
1761
1762        1. the number of added lines;
1763
1764        2. a tab;
1765
1766        3. the number of deleted lines;
1767
1768        4. a tab;
1769
1770        5. pathname (possibly with rename/copy information);
1771
1772        6. a newline.
1773
1774       When -z output option is in effect, the output is formatted this way:
1775
1776           1       2       README NUL
1777           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
1778
1779       That is:
1780
1781        1. the number of added lines;
1782
1783        2. a tab;
1784
1785        3. the number of deleted lines;
1786
1787        4. a tab;
1788
1789        5. a NUL (only exists if renamed/copied);
1790
1791        6. pathname in preimage;
1792
1793        7. a NUL (only exists if renamed/copied);
1794
1795        8. pathname in postimage (only exists if renamed/copied);
1796
1797        9. a NUL.
1798
1799       The extra NUL before the preimage path in renamed case is to allow
1800       scripts that read the output to tell if the current record being read
1801       is a single-path record or a rename/copy record without reading ahead.
1802       After reading added and deleted lines, reading up to NUL would yield
1803       the pathname, but if that is NUL, the record will show two paths.
1804

GIT

1806       Part of the git(1) suite
1807
1808
1809
1810Git 2.43.0                        11/20/2023                  GIT-DIFF-TREE(1)
Impressum