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

PRETTY FORMATS

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

RAW OUTPUT FORMAT

1360       The raw output format from "git-diff-index", "git-diff-tree",
1361       "git-diff-files" and "git diff --raw" are very similar.
1362
1363       These commands all compare two sets of things; what is compared
1364       differs:
1365
1366       git-diff-index <tree-ish>
1367           compares the <tree-ish> and the files on the filesystem.
1368
1369       git-diff-index --cached <tree-ish>
1370           compares the <tree-ish> and the index.
1371
1372       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
1373           compares the trees named by the two arguments.
1374
1375       git-diff-files [<pattern>...]
1376           compares the index and the files on the filesystem.
1377
1378       The "git-diff-tree" command begins its output by printing the hash of
1379       what is being compared. After that, all the commands print one output
1380       line per changed file.
1381
1382       An output line is formatted this way:
1383
1384           in-place edit  :100644 100644 bcd1234 0123456 M file0
1385           copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
1386           rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
1387           create         :000000 100644 0000000 1234567 A file4
1388           delete         :100644 000000 1234567 0000000 D file5
1389           unmerged       :000000 000000 0000000 0000000 U file6
1390
1391       That is, from the left to the right:
1392
1393        1. a colon.
1394
1395        2. mode for "src"; 000000 if creation or unmerged.
1396
1397        3. a space.
1398
1399        4. mode for "dst"; 000000 if deletion or unmerged.
1400
1401        5. a space.
1402
1403        6. sha1 for "src"; 0{40} if creation or unmerged.
1404
1405        7. a space.
1406
1407        8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1408
1409        9. a space.
1410
1411       10. status, followed by optional "score" number.
1412
1413       11. a tab or a NUL when -z option is used.
1414
1415       12. path for "src"
1416
1417       13. a tab or a NUL when -z option is used; only exists for C or R.
1418
1419       14. path for "dst"; only exists for C or R.
1420
1421       15. an LF or a NUL when -z option is used, to terminate the record.
1422
1423       Possible status letters are:
1424
1425       •   A: addition of a file
1426
1427       •   C: copy of a file into a new one
1428
1429       •   D: deletion of a file
1430
1431       •   M: modification of the contents or mode of a file
1432
1433       •   R: renaming of a file
1434
1435       •   T: change in the type of the file
1436
1437       •   U: file is unmerged (you must complete the merge before it can be
1438           committed)
1439
1440       •   X: "unknown" change type (most probably a bug, please report it)
1441
1442       Status letters C and R are always followed by a score (denoting the
1443       percentage of similarity between the source and target of the move or
1444       copy). Status letter M may be followed by a score (denoting the
1445       percentage of dissimilarity) for file rewrites.
1446
1447       <sha1> is shown as all 0’s if a file is new on the filesystem and it is
1448       out of sync with the index.
1449
1450       Example:
1451
1452           :100644 100644 5be4a4a 0000000 M file.c
1453
1454       Without the -z option, pathnames with "unusual" characters are quoted
1455       as explained for the configuration variable core.quotePath (see git-
1456       config(1)). Using -z the filename is output verbatim and the line is
1457       terminated by a NUL byte.
1458

DIFF FORMAT FOR MERGES

1460       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
1461       --cc option to generate diff output also for merge commits. The output
1462       differs from the format described above in the following way:
1463
1464        1. there is a colon for each parent
1465
1466        2. there are more "src" modes and "src" sha1
1467
1468        3. status is concatenated status characters for each parent
1469
1470        4. no optional "score" number
1471
1472        5. tab-separated pathname(s) of the file
1473
1474       For -c and --cc, only the destination or final path is shown even if
1475       the file was renamed on any side of history. With --combined-all-paths,
1476       the name of the path in each parent is shown followed by the name of
1477       the path in the merge commit.
1478
1479       Examples for -c and --cc without --combined-all-paths:
1480
1481           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c
1482           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       bar.sh
1483           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       phooey.c
1484
1485       Examples when --combined-all-paths added to either -c or --cc:
1486
1487           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c  desc.c  desc.c
1488           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       foo.sh  bar.sh  bar.sh
1489           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       fooey.c fuey.c  phooey.c
1490
1491       Note that combined diff lists only files which were modified from all
1492       parents.
1493

GENERATING PATCH TEXT WITH -P

1495       Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
1496       diff-tree(1), or git-diff-files(1) with the -p option produces patch
1497       text. You can customize the creation of patch text via the
1498       GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables (see
1499       git(1)), and the diff attribute (see gitattributes(5)).
1500
1501       What the -p option produces is slightly different from the traditional
1502       diff format:
1503
1504        1. It is preceded with a "git diff" header that looks like this:
1505
1506               diff --git a/file1 b/file2
1507
1508           The a/ and b/ filenames are the same unless rename/copy is
1509           involved. Especially, even for a creation or a deletion, /dev/null
1510           is not used in place of the a/ or b/ filenames.
1511
1512           When rename/copy is involved, file1 and file2 show the name of the
1513           source file of the rename/copy and the name of the file that
1514           rename/copy produces, respectively.
1515
1516        2. It is followed by one or more extended header lines:
1517
1518               old mode <mode>
1519               new mode <mode>
1520               deleted file mode <mode>
1521               new file mode <mode>
1522               copy from <path>
1523               copy to <path>
1524               rename from <path>
1525               rename to <path>
1526               similarity index <number>
1527               dissimilarity index <number>
1528               index <hash>..<hash> <mode>
1529
1530           File modes are printed as 6-digit octal numbers including the file
1531           type and file permission bits.
1532
1533           Path names in extended headers do not include the a/ and b/
1534           prefixes.
1535
1536           The similarity index is the percentage of unchanged lines, and the
1537           dissimilarity index is the percentage of changed lines. It is a
1538           rounded down integer, followed by a percent sign. The similarity
1539           index value of 100% is thus reserved for two equal files, while
1540           100% dissimilarity means that no line from the old file made it
1541           into the new one.
1542
1543           The index line includes the blob object names before and after the
1544           change. The <mode> is included if the file mode does not change;
1545           otherwise, separate lines indicate the old and the new mode.
1546
1547        3. Pathnames with "unusual" characters are quoted as explained for the
1548           configuration variable core.quotePath (see git-config(1)).
1549
1550        4. All the file1 files in the output refer to files before the commit,
1551           and all the file2 files refer to files after the commit. It is
1552           incorrect to apply each change to each file sequentially. For
1553           example, this patch will swap a and b:
1554
1555               diff --git a/a b/b
1556               rename from a
1557               rename to b
1558               diff --git a/b b/a
1559               rename from b
1560               rename to a
1561
1562        5. Hunk headers mention the name of the function to which the hunk
1563           applies. See "Defining a custom hunk-header" in gitattributes(5)
1564           for details of how to tailor to this to specific languages.
1565

COMBINED DIFF FORMAT

1567       Any diff-generating command can take the -c or --cc option to produce a
1568       combined diff when showing a merge. This is the default format when
1569       showing merges with git-diff(1) or git-show(1). Note also that you can
1570       give suitable --diff-merges option to any of these commands to force
1571       generation of diffs in specific format.
1572
1573       A "combined diff" format looks like this:
1574
1575           diff --combined describe.c
1576           index fabadb8,cc95eb0..4866510
1577           --- a/describe.c
1578           +++ b/describe.c
1579           @@@ -98,20 -98,12 +98,20 @@@
1580                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1581             }
1582
1583           - static void describe(char *arg)
1584            -static void describe(struct commit *cmit, int last_one)
1585           ++static void describe(char *arg, int last_one)
1586             {
1587            +      unsigned char sha1[20];
1588            +      struct commit *cmit;
1589                   struct commit_list *list;
1590                   static int initialized = 0;
1591                   struct commit_name *n;
1592
1593            +      if (get_sha1(arg, sha1) < 0)
1594            +              usage(describe_usage);
1595            +      cmit = lookup_commit_reference(sha1);
1596            +      if (!cmit)
1597            +              usage(describe_usage);
1598            +
1599                   if (!initialized) {
1600                           initialized = 1;
1601                           for_each_ref(get_name);
1602
1603        1. It is preceded with a "git diff" header, that looks like this (when
1604           the -c option is used):
1605
1606               diff --combined file
1607
1608           or like this (when the --cc option is used):
1609
1610               diff --cc file
1611
1612        2. It is followed by one or more extended header lines (this example
1613           shows a merge with two parents):
1614
1615               index <hash>,<hash>..<hash>
1616               mode <mode>,<mode>..<mode>
1617               new file mode <mode>
1618               deleted file mode <mode>,<mode>
1619
1620           The mode <mode>,<mode>..<mode> line appears only if at least one of
1621           the <mode> is different from the rest. Extended headers with
1622           information about detected contents movement (renames and copying
1623           detection) are designed to work with diff of two <tree-ish> and are
1624           not used by combined diff format.
1625
1626        3. It is followed by two-line from-file/to-file header
1627
1628               --- a/file
1629               +++ b/file
1630
1631           Similar to two-line header for traditional unified diff format,
1632           /dev/null is used to signal created or deleted files.
1633
1634           However, if the --combined-all-paths option is provided, instead of
1635           a two-line from-file/to-file you get a N+1 line from-file/to-file
1636           header, where N is the number of parents in the merge commit
1637
1638               --- a/file
1639               --- a/file
1640               --- a/file
1641               +++ b/file
1642
1643           This extended format can be useful if rename or copy detection is
1644           active, to allow you to see the original name of the file in
1645           different parents.
1646
1647        4. Chunk header format is modified to prevent people from accidentally
1648           feeding it to patch -p1. Combined diff format was created for
1649           review of merge commit changes, and was not meant to be applied.
1650           The change is similar to the change in the extended index header:
1651
1652               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
1653
1654           There are (number of parents + 1) @ characters in the chunk header
1655           for combined diff format.
1656
1657       Unlike the traditional unified diff format, which shows two files A and
1658       B with a single column that has - (minus — appears in A but removed in
1659       B), + (plus — missing in A but added to B), or " " (space — unchanged)
1660       prefix, this format compares two or more files file1, file2,... with
1661       one file X, and shows how X differs from each of fileN. One column for
1662       each of fileN is prepended to the output line to note how X’s line is
1663       different from it.
1664
1665       A - character in the column N means that the line appears in fileN but
1666       it does not appear in the result. A + character in the column N means
1667       that the line appears in the result, and fileN does not have that line
1668       (in other words, the line was added, from the point of view of that
1669       parent).
1670
1671       In the above example output, the function signature was changed from
1672       both files (hence two - removals from both file1 and file2, plus ++ to
1673       mean one line that was added does not appear in either file1 or file2).
1674       Also eight other lines are the same from file1 but do not appear in
1675       file2 (hence prefixed with +).
1676
1677       When shown by git diff-tree -c, it compares the parents of a merge
1678       commit with the merge result (i.e. file1..fileN are the parents). When
1679       shown by git diff-files -c, it compares the two unresolved merge
1680       parents with the working tree file (i.e. file1 is stage 2 aka "our
1681       version", file2 is stage 3 aka "their version").
1682

OTHER DIFF FORMATS

1684       The --summary option describes newly added, deleted, renamed and copied
1685       files. The --stat option adds diffstat(1) graph to the output. These
1686       options can be combined with other options, such as -p, and are meant
1687       for human consumption.
1688
1689       When showing a change that involves a rename or a copy, --stat output
1690       formats the pathnames compactly by combining common prefix and suffix
1691       of the pathnames. For example, a change that moves arch/i386/Makefile
1692       to arch/x86/Makefile while modifying 4 lines will be shown like this:
1693
1694           arch/{i386 => x86}/Makefile    |   4 +--
1695
1696       The --numstat option gives the diffstat(1) information but is designed
1697       for easier machine consumption. An entry in --numstat output looks like
1698       this:
1699
1700           1       2       README
1701           3       1       arch/{i386 => x86}/Makefile
1702
1703       That is, from left to right:
1704
1705        1. the number of added lines;
1706
1707        2. a tab;
1708
1709        3. the number of deleted lines;
1710
1711        4. a tab;
1712
1713        5. pathname (possibly with rename/copy information);
1714
1715        6. a newline.
1716
1717       When -z output option is in effect, the output is formatted this way:
1718
1719           1       2       README NUL
1720           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
1721
1722       That is:
1723
1724        1. the number of added lines;
1725
1726        2. a tab;
1727
1728        3. the number of deleted lines;
1729
1730        4. a tab;
1731
1732        5. a NUL (only exists if renamed/copied);
1733
1734        6. pathname in preimage;
1735
1736        7. a NUL (only exists if renamed/copied);
1737
1738        8. pathname in postimage (only exists if renamed/copied);
1739
1740        9. a NUL.
1741
1742       The extra NUL before the preimage path in renamed case is to allow
1743       scripts that read the output to tell if the current record being read
1744       is a single-path record or a rename/copy record without reading ahead.
1745       After reading added and deleted lines, reading up to NUL would yield
1746       the pathname, but if that is NUL, the record will show two paths.
1747

GIT

1749       Part of the git(1) suite
1750
1751
1752
1753Git 2.33.1                        2021-10-12                  GIT-DIFF-TREE(1)
Impressum