1GIT-DIFF-TREE(1) Git Manual GIT-DIFF-TREE(1)
2
3
4
6 git-diff-tree - Compares the content and mode of blobs found via two
7 tree objects
8
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
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
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.
206
207 --name-status
208 Show only names and status of changed files. See the description of
209 the --diff-filter option on what the status letters mean.
210
211 --submodule[=<format>]
212 Specify how differences in submodules are shown. When specifying
213 --submodule=short the short format is used. This format just shows
214 the names of the commits at the beginning and end of the range.
215 When --submodule or --submodule=log is specified, the log format is
216 used. This format lists the commits in the range like git-
217 submodule(1) summary does. When --submodule=diff is specified, the
218 diff format is used. This format shows an inline diff of the
219 changes in the submodule contents between the commit range.
220 Defaults to diff.submodule or the short format if the config option
221 is unset.
222
223 --color[=<when>]
224 Show colored diff. --color (i.e. without =<when>) is the same as
225 --color=always. <when> can be one of always, never, or auto.
226
227 --no-color
228 Turn off colored diff. It is the same as --color=never.
229
230 --color-moved[=<mode>]
231 Moved lines of code are colored differently. The <mode> defaults to
232 no if the option is not given and to zebra if the option with no
233 mode is given. The mode must be one of:
234
235 no
236 Moved lines are not highlighted.
237
238 default
239 Is a synonym for zebra. This may change to a more sensible mode
240 in the future.
241
242 plain
243 Any line that is added in one location and was removed in
244 another location will be colored with color.diff.newMoved.
245 Similarly color.diff.oldMoved will be used for removed lines
246 that are added somewhere else in the diff. This mode picks up
247 any moved line, but it is not very useful in a review to
248 determine if a block of code was moved without permutation.
249
250 blocks
251 Blocks of moved text of at least 20 alphanumeric characters are
252 detected greedily. The detected blocks are painted using either
253 the color.diff.{old,new}Moved color. Adjacent blocks cannot be
254 told apart.
255
256 zebra
257 Blocks of moved text are detected as in blocks mode. The blocks
258 are painted using either the color.diff.{old,new}Moved color or
259 color.diff.{old,new}MovedAlternative. The change between the
260 two colors indicates that a new block was detected.
261
262 dimmed-zebra
263 Similar to zebra, but additional dimming of uninteresting parts
264 of moved code is performed. The bordering lines of two adjacent
265 blocks are considered interesting, the rest is uninteresting.
266 dimmed_zebra is a deprecated synonym.
267
268 --no-color-moved
269 Turn off move detection. This can be used to override configuration
270 settings. It is the same as --color-moved=no.
271
272 --color-moved-ws=<modes>
273 This configures how whitespace is ignored when performing the move
274 detection for --color-moved. These modes can be given as a comma
275 separated list:
276
277 no
278 Do not ignore whitespace when performing move detection.
279
280 ignore-space-at-eol
281 Ignore changes in whitespace at EOL.
282
283 ignore-space-change
284 Ignore changes in amount of whitespace. This ignores whitespace
285 at line end, and considers all other sequences of one or more
286 whitespace characters to be equivalent.
287
288 ignore-all-space
289 Ignore whitespace when comparing lines. This ignores
290 differences even if one line has whitespace where the other
291 line has none.
292
293 allow-indentation-change
294 Initially ignore any whitespace in the move detection, then
295 group the moved code blocks only into a block if the change in
296 whitespace is the same per line. This is incompatible with the
297 other modes.
298
299 --no-color-moved-ws
300 Do not ignore whitespace when performing move detection. This can
301 be used to override configuration settings. It is the same as
302 --color-moved-ws=no.
303
304 --word-diff[=<mode>]
305 Show a word diff, using the <mode> to delimit changed words. By
306 default, words are delimited by whitespace; see --word-diff-regex
307 below. The <mode> defaults to plain, and must be one of:
308
309 color
310 Highlight changed words using only colors. Implies --color.
311
312 plain
313 Show words as [-removed-] and {+added+}. Makes no attempts to
314 escape the delimiters if they appear in the input, so the
315 output may be ambiguous.
316
317 porcelain
318 Use a special line-based format intended for script
319 consumption. Added/removed/unchanged runs are printed in the
320 usual unified diff format, starting with a +/-/` ` character at
321 the beginning of the line and extending to the end of the line.
322 Newlines in the input are represented by a tilde ~ on a line of
323 its own.
324
325 none
326 Disable word diff again.
327
328 Note that despite the name of the first mode, color is used to
329 highlight the changed parts in all modes if enabled.
330
331 --word-diff-regex=<regex>
332 Use <regex> to decide what a word is, instead of considering runs
333 of non-whitespace to be a word. Also implies --word-diff unless it
334 was already enabled.
335
336 Every non-overlapping match of the <regex> is considered a word.
337 Anything between these matches is considered whitespace and
338 ignored(!) for the purposes of finding differences. You may want to
339 append |[^[:space:]] to your regular expression to make sure that
340 it matches all non-whitespace characters. A match that contains a
341 newline is silently truncated(!) at the newline.
342
343 For example, --word-diff-regex=. will treat each character as a
344 word and, correspondingly, show differences character by character.
345
346 The regex can also be set via a diff driver or configuration
347 option, see gitattributes(5) or git-config(1). Giving it explicitly
348 overrides any diff driver or configuration setting. Diff drivers
349 override configuration settings.
350
351 --color-words[=<regex>]
352 Equivalent to --word-diff=color plus (if a regex was specified)
353 --word-diff-regex=<regex>.
354
355 --no-renames
356 Turn off rename detection, even when the configuration file gives
357 the default to do so.
358
359 --[no-]rename-empty
360 Whether to use empty blobs as rename source.
361
362 --check
363 Warn if changes introduce conflict markers or whitespace errors.
364 What are considered whitespace errors is controlled by
365 core.whitespace configuration. By default, trailing whitespaces
366 (including lines that consist solely of whitespaces) and a space
367 character that is immediately followed by a tab character inside
368 the initial indent of the line are considered whitespace errors.
369 Exits with non-zero status if problems are found. Not compatible
370 with --exit-code.
371
372 --ws-error-highlight=<kind>
373 Highlight whitespace errors in the context, old or new lines of the
374 diff. Multiple values are separated by comma, none resets previous
375 values, default reset the list to new and all is a shorthand for
376 old,new,context. When this option is not given, and the
377 configuration variable diff.wsErrorHighlight is not set, only
378 whitespace errors in new lines are highlighted. The whitespace
379 errors are colored with color.diff.whitespace.
380
381 --full-index
382 Instead of the first handful of characters, show the full pre- and
383 post-image blob object names on the "index" line when generating
384 patch format output.
385
386 --binary
387 In addition to --full-index, output a binary diff that can be
388 applied with git-apply. Implies --patch.
389
390 --abbrev[=<n>]
391 Instead of showing the full 40-byte hexadecimal object name in
392 diff-raw format output and diff-tree header lines, show the
393 shortest prefix that is at least <n> hexdigits long that uniquely
394 refers the object. In diff-patch output format, --full-index takes
395 higher precedence, i.e. if --full-index is specified, full blob
396 names will be shown regardless of --abbrev. Non default number of
397 digits can be specified with --abbrev=<n>.
398
399 -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
400 Break complete rewrite changes into pairs of delete and create.
401 This serves two purposes:
402
403 It affects the way a change that amounts to a total rewrite of a
404 file not as a series of deletion and insertion mixed together with
405 a very few lines that happen to match textually as the context, but
406 as a single deletion of everything old followed by a single
407 insertion of everything new, and the number m controls this aspect
408 of the -B option (defaults to 60%). -B/70% specifies that less
409 than 30% of the original should remain in the result for Git to
410 consider it a total rewrite (i.e. otherwise the resulting patch
411 will be a series of deletion and insertion mixed together with
412 context lines).
413
414 When used with -M, a totally-rewritten file is also considered as
415 the source of a rename (usually -M only considers a file that
416 disappeared as the source of a rename), and the number n controls
417 this aspect of the -B option (defaults to 50%). -B20% specifies
418 that a change with addition and deletion compared to 20% or more of
419 the file’s size are eligible for being picked up as a possible
420 source of a rename to another file.
421
422 -M[<n>], --find-renames[=<n>]
423 Detect renames. If n is specified, it is a threshold on the
424 similarity index (i.e. amount of addition/deletions compared to the
425 file’s size). For example, -M90% means Git should consider a
426 delete/add pair to be a rename if more than 90% of the file hasn’t
427 changed. Without a % sign, the number is to be read as a fraction,
428 with a decimal point before it. I.e., -M5 becomes 0.5, and is thus
429 the same as -M50%. Similarly, -M05 is the same as -M5%. To limit
430 detection to exact renames, use -M100%. The default similarity
431 index is 50%.
432
433 -C[<n>], --find-copies[=<n>]
434 Detect copies as well as renames. See also --find-copies-harder. If
435 n is specified, it has the same meaning as for -M<n>.
436
437 --find-copies-harder
438 For performance reasons, by default, -C option finds copies only if
439 the original file of the copy was modified in the same changeset.
440 This flag makes the command inspect unmodified files as candidates
441 for the source of copy. This is a very expensive operation for
442 large projects, so use it with caution. Giving more than one -C
443 option has the same effect.
444
445 -D, --irreversible-delete
446 Omit the preimage for deletes, i.e. print only the header but not
447 the diff between the preimage and /dev/null. The resulting patch is
448 not meant to be applied with patch or git apply; this is solely for
449 people who want to just concentrate on reviewing the text after the
450 change. In addition, the output obviously lacks enough information
451 to apply such a patch in reverse, even manually, hence the name of
452 the option.
453
454 When used together with -B, omit also the preimage in the deletion
455 part of a delete/create pair.
456
457 -l<num>
458 The -M and -C options require O(n^2) processing time where n is the
459 number of potential rename/copy targets. This option prevents
460 rename/copy detection from running if the number of rename/copy
461 targets exceeds the specified number.
462
463 --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
464 Select only files that are Added (A), Copied (C), Deleted (D),
465 Modified (M), Renamed (R), have their type (i.e. regular file,
466 symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
467 (X), or have had their pairing Broken (B). Any combination of the
468 filter characters (including none) can be used. When *
469 (All-or-none) is added to the combination, all paths are selected
470 if there is any file that matches other criteria in the comparison;
471 if there is no file that matches other criteria, nothing is
472 selected.
473
474 Also, these upper-case letters can be downcased to exclude. E.g.
475 --diff-filter=ad excludes added and deleted paths.
476
477 Note that not all diffs can feature all types. For instance, diffs
478 from the index to the working tree can never have Added entries
479 (because the set of paths included in the diff is limited by what
480 is in the index). Similarly, copied and renamed entries cannot
481 appear if detection for those types is disabled.
482
483 -S<string>
484 Look for differences that change the number of occurrences of the
485 specified string (i.e. addition/deletion) in a file. Intended for
486 the scripter’s use.
487
488 It is useful when you’re looking for an exact block of code (like a
489 struct), and want to know the history of that block since it first
490 came into being: use the feature iteratively to feed the
491 interesting block in the preimage back into -S, and keep going
492 until you get the very first version of the block.
493
494 Binary files are searched as well.
495
496 -G<regex>
497 Look for differences whose patch text contains added/removed lines
498 that match <regex>.
499
500 To illustrate the difference between -S<regex> --pickaxe-regex and
501 -G<regex>, consider a commit with the following diff in the same
502 file:
503
504 + return frotz(nitfol, two->ptr, 1, 0);
505 ...
506 - hit = frotz(nitfol, mf2.ptr, 1, 0);
507
508 While git log -G"frotz\(nitfol" will show this commit, git log
509 -S"frotz\(nitfol" --pickaxe-regex will not (because the number of
510 occurrences of that string did not change).
511
512 Unless --text is supplied patches of binary files without a
513 textconv filter will be ignored.
514
515 See the pickaxe entry in gitdiffcore(7) for more information.
516
517 --find-object=<object-id>
518 Look for differences that change the number of occurrences of the
519 specified object. Similar to -S, just the argument is different in
520 that it doesn’t search for a specific string but for a specific
521 object id.
522
523 The object can be a blob or a submodule commit. It implies the -t
524 option in git-log to also find trees.
525
526 --pickaxe-all
527 When -S or -G finds a change, show all the changes in that
528 changeset, not just the files that contain the change in <string>.
529
530 --pickaxe-regex
531 Treat the <string> given to -S as an extended POSIX regular
532 expression to match.
533
534 -O<orderfile>
535 Control the order in which files appear in the output. This
536 overrides the diff.orderFile configuration variable (see git-
537 config(1)). To cancel diff.orderFile, use -O/dev/null.
538
539 The output order is determined by the order of glob patterns in
540 <orderfile>. All files with pathnames that match the first pattern
541 are output first, all files with pathnames that match the second
542 pattern (but not the first) are output next, and so on. All files
543 with pathnames that do not match any pattern are output last, as if
544 there was an implicit match-all pattern at the end of the file. If
545 multiple pathnames have the same rank (they match the same pattern
546 but no earlier patterns), their output order relative to each other
547 is the normal order.
548
549 <orderfile> is parsed as follows:
550
551 • Blank lines are ignored, so they can be used as separators for
552 readability.
553
554 • Lines starting with a hash ("#") are ignored, so they can be
555 used for comments. Add a backslash ("\") to the beginning of
556 the pattern if it starts with a hash.
557
558 • Each other line contains a single pattern.
559
560 Patterns have the same syntax and semantics as patterns used for
561 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
562 matches a pattern if removing any number of the final pathname
563 components matches the pattern. For example, the pattern "foo*bar"
564 matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".
565
566 --skip-to=<file>, --rotate-to=<file>
567 Discard the files before the named <file> from the output (i.e.
568 skip to), or move them to the end of the output (i.e. rotate to).
569 These were invented primarily for use of the git difftool command,
570 and may not be very useful otherwise.
571
572 -R
573 Swap two inputs; that is, show differences from index or on-disk
574 file to tree contents.
575
576 --relative[=<path>], --no-relative
577 When run from a subdirectory of the project, it can be told to
578 exclude changes outside the directory and show pathnames relative
579 to it with this option. When you are not in a subdirectory (e.g. in
580 a bare repository), you can name which subdirectory to make the
581 output relative to by giving a <path> as an argument.
582 --no-relative can be used to countermand both diff.relative config
583 option and previous --relative.
584
585 -a, --text
586 Treat all files as text.
587
588 --ignore-cr-at-eol
589 Ignore carriage-return at the end of line when doing a comparison.
590
591 --ignore-space-at-eol
592 Ignore changes in whitespace at EOL.
593
594 -b, --ignore-space-change
595 Ignore changes in amount of whitespace. This ignores whitespace at
596 line end, and considers all other sequences of one or more
597 whitespace characters to be equivalent.
598
599 -w, --ignore-all-space
600 Ignore whitespace when comparing lines. This ignores differences
601 even if one line has whitespace where the other line has none.
602
603 --ignore-blank-lines
604 Ignore changes whose lines are all blank.
605
606 -I<regex>, --ignore-matching-lines=<regex>
607 Ignore changes whose all lines match <regex>. This option may be
608 specified more than once.
609
610 --inter-hunk-context=<lines>
611 Show the context between diff hunks, up to the specified number of
612 lines, thereby fusing hunks that are close to each other. Defaults
613 to diff.interHunkContext or 0 if the config option is unset.
614
615 -W, --function-context
616 Show whole function as context lines for each change. The function
617 names are determined in the same way as git diff works out patch
618 hunk headers (see Defining a custom hunk-header in
619 gitattributes(5)).
620
621 --exit-code
622 Make the program exit with codes similar to diff(1). That is, it
623 exits with 1 if there were differences and 0 means no differences.
624
625 --quiet
626 Disable all output of the program. Implies --exit-code.
627
628 --ext-diff
629 Allow an external diff helper to be executed. If you set an
630 external diff driver with gitattributes(5), you need to use this
631 option with git-log(1) and friends.
632
633 --no-ext-diff
634 Disallow external diff drivers.
635
636 --textconv, --no-textconv
637 Allow (or disallow) external text conversion filters to be run when
638 comparing binary files. See gitattributes(5) for details. Because
639 textconv filters are typically a one-way conversion, the resulting
640 diff is suitable for human consumption, but cannot be applied. For
641 this reason, textconv filters are enabled by default only for git-
642 diff(1) and git-log(1), but not for git-format-patch(1) or diff
643 plumbing commands.
644
645 --ignore-submodules[=<when>]
646 Ignore changes to submodules in the diff generation. <when> can be
647 either "none", "untracked", "dirty" or "all", which is the default.
648 Using "none" will consider the submodule modified when it either
649 contains untracked or modified files or its HEAD differs from the
650 commit recorded in the superproject and can be used to override any
651 settings of the ignore option in git-config(1) or gitmodules(5).
652 When "untracked" is used submodules are not considered dirty when
653 they only contain untracked content (but they are still scanned for
654 modified content). Using "dirty" ignores all changes to the work
655 tree of submodules, only changes to the commits stored in the
656 superproject are shown (this was the behavior until 1.7.0). Using
657 "all" hides all changes to submodules.
658
659 --src-prefix=<prefix>
660 Show the given source prefix instead of "a/".
661
662 --dst-prefix=<prefix>
663 Show the given destination prefix instead of "b/".
664
665 --no-prefix
666 Do not show any source or destination prefix.
667
668 --line-prefix=<prefix>
669 Prepend an additional prefix to every line of output.
670
671 --ita-invisible-in-index
672 By default entries added by "git add -N" appear as an existing
673 empty file in "git diff" and a new file in "git diff --cached".
674 This option makes the entry appear as a new file in "git diff" and
675 non-existent in "git diff --cached". This option could be reverted
676 with --ita-visible-in-index. Both options are experimental and
677 could be removed in future.
678
679 For more detailed explanation on these common options, see also
680 gitdiffcore(7).
681
682 <tree-ish>
683 The id of a tree object.
684
685 <path>...
686 If provided, the results are limited to a subset of files matching
687 one of the provided pathspecs.
688
689 -r
690 recurse into sub-trees
691
692 -t
693 show tree entry itself as well as subtrees. Implies -r.
694
695 --root
696 When --root is specified the initial commit will be shown as a big
697 creation event. This is equivalent to a diff against the NULL tree.
698
699 --merge-base
700 Instead of comparing the <tree-ish>s directly, use the merge base
701 between the two <tree-ish>s as the "before" side. There must be two
702 <tree-ish>s given and they must both be commits.
703
704 --stdin
705 When --stdin is specified, the command does not take <tree-ish>
706 arguments from the command line. Instead, it reads lines containing
707 either two <tree>, one <commit>, or a list of <commit> from its
708 standard input. (Use a single space as separator.)
709
710 When two trees are given, it compares the first tree with the
711 second. When a single commit is given, it compares the commit with
712 its parents. The remaining commits, when given, are used as if they
713 are parents of the first commit.
714
715 When comparing two trees, the ID of both trees (separated by a
716 space and terminated by a newline) is printed before the
717 difference. When comparing commits, the ID of the first (or only)
718 commit, followed by a newline, is printed.
719
720 The following flags further affect the behavior when comparing
721 commits (but not trees).
722
723 -m
724 By default, git diff-tree --stdin does not show differences for
725 merge commits. With this flag, it shows differences to that commit
726 from all of its parents. See also -c.
727
728 -s
729 By default, git diff-tree --stdin shows differences, either in
730 machine-readable form (without -p) or in patch form (with -p). This
731 output can be suppressed. It is only useful with -v flag.
732
733 -v
734 This flag causes git diff-tree --stdin to also show the commit
735 message before the differences.
736
737 --pretty[=<format>], --format=<format>
738 Pretty-print the contents of the commit logs in a given format,
739 where <format> can be one of oneline, short, medium, full, fuller,
740 reference, email, raw, format:<string> and tformat:<string>. When
741 <format> is none of the above, and has %placeholder in it, it acts
742 as if --pretty=tformat:<format> were given.
743
744 See the "PRETTY FORMATS" section for some additional details for
745 each format. When =<format> part is omitted, it defaults to medium.
746
747 Note: you can specify the default pretty format in the repository
748 configuration (see git-config(1)).
749
750 --abbrev-commit
751 Instead of showing the full 40-byte hexadecimal commit object name,
752 show a prefix that names the object uniquely. "--abbrev=<n>" (which
753 also modifies diff output, if it is displayed) option can be used
754 to specify the minimum length of the prefix.
755
756 This should make "--pretty=oneline" a whole lot more readable for
757 people using 80-column terminals.
758
759 --no-abbrev-commit
760 Show the full 40-byte hexadecimal commit object name. This negates
761 --abbrev-commit, either explicit or implied by other options such
762 as "--oneline". It also overrides the log.abbrevCommit variable.
763
764 --oneline
765 This is a shorthand for "--pretty=oneline --abbrev-commit" used
766 together.
767
768 --encoding=<encoding>
769 The commit objects record the encoding used for the log message in
770 their encoding header; this option can be used to tell the command
771 to re-code the commit log message in the encoding preferred by the
772 user. For non plumbing commands this defaults to UTF-8. Note that
773 if an object claims to be encoded in X and we are outputting in X,
774 we will output the object verbatim; this means that invalid
775 sequences in the original commit may be copied to the output.
776
777 --expand-tabs=<n>, --expand-tabs, --no-expand-tabs
778 Perform a tab expansion (replace each tab with enough spaces to
779 fill to the next display column that is multiple of <n>) in the log
780 message before showing it in the output. --expand-tabs is a
781 short-hand for --expand-tabs=8, and --no-expand-tabs is a
782 short-hand for --expand-tabs=0, which disables tab expansion.
783
784 By default, tabs are expanded in pretty formats that indent the log
785 message by 4 spaces (i.e. medium, which is the default, full, and
786 fuller).
787
788 --notes[=<ref>]
789 Show the notes (see git-notes(1)) that annotate the commit, when
790 showing the commit log message. This is the default for git log,
791 git show and git whatchanged commands when there is no --pretty,
792 --format, or --oneline option given on the command line.
793
794 By default, the notes shown are from the notes refs listed in the
795 core.notesRef and notes.displayRef variables (or corresponding
796 environment overrides). See git-config(1) for more details.
797
798 With an optional <ref> argument, use the ref to find the notes to
799 display. The ref can specify the full refname when it begins with
800 refs/notes/; when it begins with notes/, refs/ and otherwise
801 refs/notes/ is prefixed to form a full name of the ref.
802
803 Multiple --notes options can be combined to control which notes are
804 being displayed. Examples: "--notes=foo" will show only notes from
805 "refs/notes/foo"; "--notes=foo --notes" will show both notes from
806 "refs/notes/foo" and from the default notes ref(s).
807
808 --no-notes
809 Do not show notes. This negates the above --notes option, by
810 resetting the list of notes refs from which notes are shown.
811 Options are parsed in the order given on the command line, so e.g.
812 "--notes --notes=foo --no-notes --notes=bar" will only show notes
813 from "refs/notes/bar".
814
815 --show-notes[=<ref>], --[no-]standard-notes
816 These options are deprecated. Use the above --notes/--no-notes
817 options instead.
818
819 --show-signature
820 Check the validity of a signed commit object by passing the
821 signature to gpg --verify and show the output.
822
823 --no-commit-id
824 git diff-tree outputs a line with the commit ID when applicable.
825 This flag suppressed the commit ID output.
826
827 -c
828 This flag changes the way a merge commit is displayed (which means
829 it is useful only when the command is given one <tree-ish>, or
830 --stdin). It shows the differences from each of the parents to the
831 merge result simultaneously instead of showing pairwise diff
832 between a parent and the result one at a time (which is what the -m
833 option does). Furthermore, it lists only files which were modified
834 from all parents.
835
836 --cc
837 This flag changes the way a merge commit patch is displayed, in a
838 similar way to the -c option. It implies the -c and -p options and
839 further compresses the patch output by omitting uninteresting hunks
840 whose the contents in the parents have only two variants and the
841 merge result picks one of them without modification. When all hunks
842 are uninteresting, the commit itself and the commit log message is
843 not shown, just like in any other "empty diff" case.
844
845 --combined-all-paths
846 This flag causes combined diffs (used for merge commits) to list
847 the name of the file from all parents. It thus only has effect when
848 -c or --cc are specified, and is likely only useful if filename
849 changes are detected (i.e. when either rename or copy detection
850 have been requested).
851
852 --always
853 Show the commit itself and the commit log message even if the diff
854 itself is empty.
855
857 If the commit is a merge, and if the pretty-format is not oneline,
858 email or raw, an additional line is inserted before the Author: line.
859 This line begins with "Merge: " and the hashes of ancestral commits are
860 printed, separated by spaces. Note that the listed commits may not
861 necessarily be the list of the direct parent commits if you have
862 limited your view of history: for example, if you are only interested
863 in changes related to a certain directory or file.
864
865 There are several built-in formats, and you can define additional
866 formats by setting a pretty.<name> config option to either another
867 format name, or a format: string, as described below (see git-
868 config(1)). Here are the details of the built-in formats:
869
870 • oneline
871
872 <hash> <title line>
873
874 This is designed to be as compact as possible.
875
876 • short
877
878 commit <hash>
879 Author: <author>
880
881 <title line>
882
883 • medium
884
885 commit <hash>
886 Author: <author>
887 Date: <author date>
888
889 <title line>
890
891 <full commit message>
892
893 • full
894
895 commit <hash>
896 Author: <author>
897 Commit: <committer>
898
899 <title line>
900
901 <full commit message>
902
903 • fuller
904
905 commit <hash>
906 Author: <author>
907 AuthorDate: <author date>
908 Commit: <committer>
909 CommitDate: <committer date>
910
911 <title line>
912
913 <full commit message>
914
915 • reference
916
917 <abbrev hash> (<title line>, <short author date>)
918
919 This format is used to refer to another commit in a commit message
920 and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By
921 default, the date is formatted with --date=short unless another
922 --date option is explicitly specified. As with any format: with
923 format placeholders, its output is not affected by other options
924 like --decorate and --walk-reflogs.
925
926 • email
927
928 From <hash> <date>
929 From: <author>
930 Date: <author date>
931 Subject: [PATCH] <title line>
932
933 <full commit message>
934
935 • mboxrd
936
937 Like email, but lines in the commit message starting with "From "
938 (preceded by zero or more ">") are quoted with ">" so they aren’t
939 confused as starting a new commit.
940
941 • raw
942
943 The raw format shows the entire commit exactly as stored in the
944 commit object. Notably, the hashes are displayed in full,
945 regardless of whether --abbrev or --no-abbrev are used, and parents
946 information show the true parent commits, without taking grafts or
947 history simplification into account. Note that this format affects
948 the way commits are displayed, but not the way the diff is shown
949 e.g. with git log --raw. To get full object names in a raw diff
950 format, use --no-abbrev.
951
952 • format:<string>
953
954 The format:<string> format allows you to specify which information
955 you want to show. It works a little bit like printf format, with
956 the notable exception that you get a newline with %n instead of \n.
957
958 E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
959 would show something like this:
960
961 The author of fe6e0ee was Junio C Hamano, 23 hours ago
962 The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
963
964 The placeholders are:
965
966 • Placeholders that expand to a single literal character:
967
968 %n
969 newline
970
971 %%
972 a raw %
973
974 %x00
975 print a byte from a hex code
976
977 • Placeholders that affect formatting of later placeholders:
978
979 %Cred
980 switch color to red
981
982 %Cgreen
983 switch color to green
984
985 %Cblue
986 switch color to blue
987
988 %Creset
989 reset color
990
991 %C(...)
992 color specification, as described under Values in the
993 "CONFIGURATION FILE" section of git-config(1). By default,
994 colors are shown only when enabled for log output (by
995 color.diff, color.ui, or --color, and respecting the auto
996 settings of the former if we are going to a terminal).
997 %C(auto,...) is accepted as a historical synonym for the
998 default (e.g., %C(auto,red)). Specifying %C(always,...)
999 will show the colors even when color is not otherwise
1000 enabled (though consider just using --color=always to
1001 enable color for the whole output, including this format
1002 and anything else git might color). auto alone (i.e.
1003 %C(auto)) will turn on auto coloring on the next
1004 placeholders until the color is switched again.
1005
1006 %m
1007 left (<), right (>) or boundary (-) mark
1008
1009 %w([<w>[,<i1>[,<i2>]]])
1010 switch line wrapping, like the -w option of git-
1011 shortlog(1).
1012
1013 %<(<N>[,trunc|ltrunc|mtrunc])
1014 make the next placeholder take at least N columns, padding
1015 spaces on the right if necessary. Optionally truncate at
1016 the beginning (ltrunc), the middle (mtrunc) or the end
1017 (trunc) if the output is longer than N columns. Note that
1018 truncating only works correctly with N >= 2.
1019
1020 %<|(<N>)
1021 make the next placeholder take at least until Nth columns,
1022 padding spaces on the right if necessary
1023
1024 %>(<N>), %>|(<N>)
1025 similar to %<(<N>), %<|(<N>) respectively, but padding
1026 spaces on the left
1027
1028 %>>(<N>), %>>|(<N>)
1029 similar to %>(<N>), %>|(<N>) respectively, except that if
1030 the next placeholder takes more spaces than given and there
1031 are spaces on its left, use those spaces
1032
1033 %><(<N>), %><|(<N>)
1034 similar to %<(<N>), %<|(<N>) respectively, but padding both
1035 sides (i.e. the text is centered)
1036
1037 • Placeholders that expand to information extracted from the
1038 commit:
1039
1040 %H
1041 commit hash
1042
1043 %h
1044 abbreviated commit hash
1045
1046 %T
1047 tree hash
1048
1049 %t
1050 abbreviated tree hash
1051
1052 %P
1053 parent hashes
1054
1055 %p
1056 abbreviated parent hashes
1057
1058 %an
1059 author name
1060
1061 %aN
1062 author name (respecting .mailmap, see git-shortlog(1) or
1063 git-blame(1))
1064
1065 %ae
1066 author email
1067
1068 %aE
1069 author email (respecting .mailmap, see git-shortlog(1) or
1070 git-blame(1))
1071
1072 %al
1073 author email local-part (the part before the @ sign)
1074
1075 %aL
1076 author local-part (see %al) respecting .mailmap, see git-
1077 shortlog(1) or git-blame(1))
1078
1079 %ad
1080 author date (format respects --date= option)
1081
1082 %aD
1083 author date, RFC2822 style
1084
1085 %ar
1086 author date, relative
1087
1088 %at
1089 author date, UNIX timestamp
1090
1091 %ai
1092 author date, ISO 8601-like format
1093
1094 %aI
1095 author date, strict ISO 8601 format
1096
1097 %as
1098 author date, short format (YYYY-MM-DD)
1099
1100 %cn
1101 committer name
1102
1103 %cN
1104 committer name (respecting .mailmap, see git-shortlog(1) or
1105 git-blame(1))
1106
1107 %ce
1108 committer email
1109
1110 %cE
1111 committer email (respecting .mailmap, see git-shortlog(1)
1112 or git-blame(1))
1113
1114 %cl
1115 committer email local-part (the part before the @ sign)
1116
1117 %cL
1118 committer local-part (see %cl) respecting .mailmap, see
1119 git-shortlog(1) or git-blame(1))
1120
1121 %cd
1122 committer date (format respects --date= option)
1123
1124 %cD
1125 committer date, RFC2822 style
1126
1127 %cr
1128 committer date, relative
1129
1130 %ct
1131 committer date, UNIX timestamp
1132
1133 %ci
1134 committer date, ISO 8601-like format
1135
1136 %cI
1137 committer date, strict ISO 8601 format
1138
1139 %cs
1140 committer date, short format (YYYY-MM-DD)
1141
1142 %d
1143 ref names, like the --decorate option of git-log(1)
1144
1145 %D
1146 ref names without the " (", ")" wrapping.
1147
1148 %S
1149 ref name given on the command line by which the commit was
1150 reached (like git log --source), only works with git log
1151
1152 %e
1153 encoding
1154
1155 %s
1156 subject
1157
1158 %f
1159 sanitized subject line, suitable for a filename
1160
1161 %b
1162 body
1163
1164 %B
1165 raw body (unwrapped subject and body)
1166
1167 %N
1168 commit notes
1169
1170 %GG
1171 raw verification message from GPG for a signed commit
1172
1173 %G?
1174 show "G" for a good (valid) signature, "B" for a bad
1175 signature, "U" for a good signature with unknown validity,
1176 "X" for a good signature that has expired, "Y" for a good
1177 signature made by an expired key, "R" for a good signature
1178 made by a revoked key, "E" if the signature cannot be
1179 checked (e.g. missing key) and "N" for no signature
1180
1181 %GS
1182 show the name of the signer for a signed commit
1183
1184 %GK
1185 show the key used to sign a signed commit
1186
1187 %GF
1188 show the fingerprint of the key used to sign a signed
1189 commit
1190
1191 %GP
1192 show the fingerprint of the primary key whose subkey was
1193 used to sign a signed commit
1194
1195 %GT
1196 show the trust level for the key used to sign a signed
1197 commit
1198
1199 %gD
1200 reflog selector, e.g., refs/stash@{1} or refs/stash@{2
1201 minutes ago}; the format follows the rules described for
1202 the -g option. The portion before the @ is the refname as
1203 given on the command line (so git log -g refs/heads/master
1204 would yield refs/heads/master@{0}).
1205
1206 %gd
1207 shortened reflog selector; same as %gD, but the refname
1208 portion is shortened for human readability (so
1209 refs/heads/master becomes just master).
1210
1211 %gn
1212 reflog identity name
1213
1214 %gN
1215 reflog identity name (respecting .mailmap, see git-
1216 shortlog(1) or git-blame(1))
1217
1218 %ge
1219 reflog identity email
1220
1221 %gE
1222 reflog identity email (respecting .mailmap, see git-
1223 shortlog(1) or git-blame(1))
1224
1225 %gs
1226 reflog subject
1227
1228 %(trailers[:options])
1229 display the trailers of the body as interpreted by git-
1230 interpret-trailers(1). The trailers string may be followed
1231 by a colon and zero or more comma-separated options. If any
1232 option is provided multiple times the last occurance wins.
1233
1234 The boolean options accept an optional value [=<BOOL>]. The
1235 values true, false, on, off etc. are all accepted. See the
1236 "boolean" sub-section in "EXAMPLES" in git-config(1). If a
1237 boolean option is given with no value, it’s enabled.
1238
1239 • key=<K>: only show trailers with specified key.
1240 Matching is done case-insensitively and trailing colon
1241 is optional. If option is given multiple times trailer
1242 lines matching any of the keys are shown. This option
1243 automatically enables the only option so that
1244 non-trailer lines in the trailer block are hidden. If
1245 that is not desired it can be disabled with only=false.
1246 E.g., %(trailers:key=Reviewed-by) shows trailer lines
1247 with key Reviewed-by.
1248
1249 • only[=<BOOL>]: select whether non-trailer lines from
1250 the trailer block should be included.
1251
1252 • separator=<SEP>: specify a separator inserted between
1253 trailer lines. When this option is not given each
1254 trailer line is terminated with a line feed character.
1255 The string SEP may contain the literal formatting codes
1256 described above. To use comma as separator one must use
1257 %x2C as it would otherwise be parsed as next option.
1258 E.g., %(trailers:key=Ticket,separator=%x2C ) shows all
1259 trailer lines whose key is "Ticket" separated by a
1260 comma and a space.
1261
1262 • unfold[=<BOOL>]: make it behave as if
1263 interpret-trailer’s --unfold option was given. E.g.,
1264 %(trailers:only,unfold=true) unfolds and shows all
1265 trailer lines.
1266
1267 • keyonly[=<BOOL>]: only show the key part of the
1268 trailer.
1269
1270 • valueonly[=<BOOL>]: only show the value part of the
1271 trailer.
1272
1273 • key_value_separator=<SEP>: specify a separator inserted
1274 between trailer lines. When this option is not given
1275 each trailer key-value pair is separated by ": ".
1276 Otherwise it shares the same semantics as
1277 separator=<SEP> above.
1278
1279 Note
1280 Some placeholders may depend on other options given to the revision
1281 traversal engine. For example, the %g* reflog options will insert
1282 an empty string unless we are traversing reflog entries (e.g., by
1283 git log -g). The %d and %D placeholders will use the "short"
1284 decoration format if --decorate was not already provided on the
1285 command line.
1286
1287 If you add a + (plus sign) after % of a placeholder, a line-feed is
1288 inserted immediately before the expansion if and only if the
1289 placeholder expands to a non-empty string.
1290
1291 If you add a - (minus sign) after % of a placeholder, all consecutive
1292 line-feeds immediately preceding the expansion are deleted if and only
1293 if the placeholder expands to an empty string.
1294
1295 If you add a ` ` (space) after % of a placeholder, a space is inserted
1296 immediately before the expansion if and only if the placeholder expands
1297 to a non-empty string.
1298
1299 • tformat:
1300
1301 The tformat: format works exactly like format:, except that it
1302 provides "terminator" semantics instead of "separator" semantics.
1303 In other words, each commit has the message terminator character
1304 (usually a newline) appended, rather than a separator placed
1305 between entries. This means that the final entry of a single-line
1306 format will be properly terminated with a new line, just as the
1307 "oneline" format does. For example:
1308
1309 $ git log -2 --pretty=format:%h 4da45bef \
1310 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1311 4da45be
1312 7134973 -- NO NEWLINE
1313
1314 $ git log -2 --pretty=tformat:%h 4da45bef \
1315 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1316 4da45be
1317 7134973
1318
1319 In addition, any unrecognized string that has a % in it is
1320 interpreted as if it has tformat: in front of it. For example,
1321 these two are equivalent:
1322
1323 $ git log -2 --pretty=tformat:%h 4da45bef
1324 $ git log -2 --pretty=%h 4da45bef
1325
1327 The raw output format from "git-diff-index", "git-diff-tree",
1328 "git-diff-files" and "git diff --raw" are very similar.
1329
1330 These commands all compare two sets of things; what is compared
1331 differs:
1332
1333 git-diff-index <tree-ish>
1334 compares the <tree-ish> and the files on the filesystem.
1335
1336 git-diff-index --cached <tree-ish>
1337 compares the <tree-ish> and the index.
1338
1339 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
1340 compares the trees named by the two arguments.
1341
1342 git-diff-files [<pattern>...]
1343 compares the index and the files on the filesystem.
1344
1345 The "git-diff-tree" command begins its output by printing the hash of
1346 what is being compared. After that, all the commands print one output
1347 line per changed file.
1348
1349 An output line is formatted this way:
1350
1351 in-place edit :100644 100644 bcd1234 0123456 M file0
1352 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
1353 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
1354 create :000000 100644 0000000 1234567 A file4
1355 delete :100644 000000 1234567 0000000 D file5
1356 unmerged :000000 000000 0000000 0000000 U file6
1357
1358 That is, from the left to the right:
1359
1360 1. a colon.
1361
1362 2. mode for "src"; 000000 if creation or unmerged.
1363
1364 3. a space.
1365
1366 4. mode for "dst"; 000000 if deletion or unmerged.
1367
1368 5. a space.
1369
1370 6. sha1 for "src"; 0{40} if creation or unmerged.
1371
1372 7. a space.
1373
1374 8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1375
1376 9. a space.
1377
1378 10. status, followed by optional "score" number.
1379
1380 11. a tab or a NUL when -z option is used.
1381
1382 12. path for "src"
1383
1384 13. a tab or a NUL when -z option is used; only exists for C or R.
1385
1386 14. path for "dst"; only exists for C or R.
1387
1388 15. an LF or a NUL when -z option is used, to terminate the record.
1389
1390 Possible status letters are:
1391
1392 • A: addition of a file
1393
1394 • C: copy of a file into a new one
1395
1396 • D: deletion of a file
1397
1398 • M: modification of the contents or mode of a file
1399
1400 • R: renaming of a file
1401
1402 • T: change in the type of the file
1403
1404 • U: file is unmerged (you must complete the merge before it can be
1405 committed)
1406
1407 • X: "unknown" change type (most probably a bug, please report it)
1408
1409 Status letters C and R are always followed by a score (denoting the
1410 percentage of similarity between the source and target of the move or
1411 copy). Status letter M may be followed by a score (denoting the
1412 percentage of dissimilarity) for file rewrites.
1413
1414 <sha1> is shown as all 0’s if a file is new on the filesystem and it is
1415 out of sync with the index.
1416
1417 Example:
1418
1419 :100644 100644 5be4a4a 0000000 M file.c
1420
1421 Without the -z option, pathnames with "unusual" characters are quoted
1422 as explained for the configuration variable core.quotePath (see git-
1423 config(1)). Using -z the filename is output verbatim and the line is
1424 terminated by a NUL byte.
1425
1427 "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
1428 --cc option to generate diff output also for merge commits. The output
1429 differs from the format described above in the following way:
1430
1431 1. there is a colon for each parent
1432
1433 2. there are more "src" modes and "src" sha1
1434
1435 3. status is concatenated status characters for each parent
1436
1437 4. no optional "score" number
1438
1439 5. tab-separated pathname(s) of the file
1440
1441 For -c and --cc, only the destination or final path is shown even if
1442 the file was renamed on any side of history. With --combined-all-paths,
1443 the name of the path in each parent is shown followed by the name of
1444 the path in the merge commit.
1445
1446 Examples for -c and --cc without --combined-all-paths:
1447
1448 ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c
1449 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh
1450 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c
1451
1452 Examples when --combined-all-paths added to either -c or --cc:
1453
1454 ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c
1455 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
1456 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c
1457
1458 Note that combined diff lists only files which were modified from all
1459 parents.
1460
1462 Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
1463 diff-tree(1), or git-diff-files(1) with the -p option produces patch
1464 text. You can customize the creation of patch text via the
1465 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables (see
1466 git(1)).
1467
1468 What the -p option produces is slightly different from the traditional
1469 diff format:
1470
1471 1. It is preceded with a "git diff" header that looks like this:
1472
1473 diff --git a/file1 b/file2
1474
1475 The a/ and b/ filenames are the same unless rename/copy is
1476 involved. Especially, even for a creation or a deletion, /dev/null
1477 is not used in place of the a/ or b/ filenames.
1478
1479 When rename/copy is involved, file1 and file2 show the name of the
1480 source file of the rename/copy and the name of the file that
1481 rename/copy produces, respectively.
1482
1483 2. It is followed by one or more extended header lines:
1484
1485 old mode <mode>
1486 new mode <mode>
1487 deleted file mode <mode>
1488 new file mode <mode>
1489 copy from <path>
1490 copy to <path>
1491 rename from <path>
1492 rename to <path>
1493 similarity index <number>
1494 dissimilarity index <number>
1495 index <hash>..<hash> <mode>
1496
1497 File modes are printed as 6-digit octal numbers including the file
1498 type and file permission bits.
1499
1500 Path names in extended headers do not include the a/ and b/
1501 prefixes.
1502
1503 The similarity index is the percentage of unchanged lines, and the
1504 dissimilarity index is the percentage of changed lines. It is a
1505 rounded down integer, followed by a percent sign. The similarity
1506 index value of 100% is thus reserved for two equal files, while
1507 100% dissimilarity means that no line from the old file made it
1508 into the new one.
1509
1510 The index line includes the blob object names before and after the
1511 change. The <mode> is included if the file mode does not change;
1512 otherwise, separate lines indicate the old and the new mode.
1513
1514 3. Pathnames with "unusual" characters are quoted as explained for the
1515 configuration variable core.quotePath (see git-config(1)).
1516
1517 4. All the file1 files in the output refer to files before the commit,
1518 and all the file2 files refer to files after the commit. It is
1519 incorrect to apply each change to each file sequentially. For
1520 example, this patch will swap a and b:
1521
1522 diff --git a/a b/b
1523 rename from a
1524 rename to b
1525 diff --git a/b b/a
1526 rename from b
1527 rename to a
1528
1530 Any diff-generating command can take the -c or --cc option to produce a
1531 combined diff when showing a merge. This is the default format when
1532 showing merges with git-diff(1) or git-show(1). Note also that you can
1533 give suitable --diff-merges option to any of these commands to force
1534 generation of diffs in specific format.
1535
1536 A "combined diff" format looks like this:
1537
1538 diff --combined describe.c
1539 index fabadb8,cc95eb0..4866510
1540 --- a/describe.c
1541 +++ b/describe.c
1542 @@@ -98,20 -98,12 +98,20 @@@
1543 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1544 }
1545
1546 - static void describe(char *arg)
1547 -static void describe(struct commit *cmit, int last_one)
1548 ++static void describe(char *arg, int last_one)
1549 {
1550 + unsigned char sha1[20];
1551 + struct commit *cmit;
1552 struct commit_list *list;
1553 static int initialized = 0;
1554 struct commit_name *n;
1555
1556 + if (get_sha1(arg, sha1) < 0)
1557 + usage(describe_usage);
1558 + cmit = lookup_commit_reference(sha1);
1559 + if (!cmit)
1560 + usage(describe_usage);
1561 +
1562 if (!initialized) {
1563 initialized = 1;
1564 for_each_ref(get_name);
1565
1566 1. It is preceded with a "git diff" header, that looks like this (when
1567 the -c option is used):
1568
1569 diff --combined file
1570
1571 or like this (when the --cc option is used):
1572
1573 diff --cc file
1574
1575 2. It is followed by one or more extended header lines (this example
1576 shows a merge with two parents):
1577
1578 index <hash>,<hash>..<hash>
1579 mode <mode>,<mode>..<mode>
1580 new file mode <mode>
1581 deleted file mode <mode>,<mode>
1582
1583 The mode <mode>,<mode>..<mode> line appears only if at least one of
1584 the <mode> is different from the rest. Extended headers with
1585 information about detected contents movement (renames and copying
1586 detection) are designed to work with diff of two <tree-ish> and are
1587 not used by combined diff format.
1588
1589 3. It is followed by two-line from-file/to-file header
1590
1591 --- a/file
1592 +++ b/file
1593
1594 Similar to two-line header for traditional unified diff format,
1595 /dev/null is used to signal created or deleted files.
1596
1597 However, if the --combined-all-paths option is provided, instead of
1598 a two-line from-file/to-file you get a N+1 line from-file/to-file
1599 header, where N is the number of parents in the merge commit
1600
1601 --- a/file
1602 --- a/file
1603 --- a/file
1604 +++ b/file
1605
1606 This extended format can be useful if rename or copy detection is
1607 active, to allow you to see the original name of the file in
1608 different parents.
1609
1610 4. Chunk header format is modified to prevent people from accidentally
1611 feeding it to patch -p1. Combined diff format was created for
1612 review of merge commit changes, and was not meant to be applied.
1613 The change is similar to the change in the extended index header:
1614
1615 @@@ <from-file-range> <from-file-range> <to-file-range> @@@
1616
1617 There are (number of parents + 1) @ characters in the chunk header
1618 for combined diff format.
1619
1620 Unlike the traditional unified diff format, which shows two files A and
1621 B with a single column that has - (minus — appears in A but removed in
1622 B), + (plus — missing in A but added to B), or " " (space — unchanged)
1623 prefix, this format compares two or more files file1, file2,... with
1624 one file X, and shows how X differs from each of fileN. One column for
1625 each of fileN is prepended to the output line to note how X’s line is
1626 different from it.
1627
1628 A - character in the column N means that the line appears in fileN but
1629 it does not appear in the result. A + character in the column N means
1630 that the line appears in the result, and fileN does not have that line
1631 (in other words, the line was added, from the point of view of that
1632 parent).
1633
1634 In the above example output, the function signature was changed from
1635 both files (hence two - removals from both file1 and file2, plus ++ to
1636 mean one line that was added does not appear in either file1 or file2).
1637 Also eight other lines are the same from file1 but do not appear in
1638 file2 (hence prefixed with +).
1639
1640 When shown by git diff-tree -c, it compares the parents of a merge
1641 commit with the merge result (i.e. file1..fileN are the parents). When
1642 shown by git diff-files -c, it compares the two unresolved merge
1643 parents with the working tree file (i.e. file1 is stage 2 aka "our
1644 version", file2 is stage 3 aka "their version").
1645
1647 The --summary option describes newly added, deleted, renamed and copied
1648 files. The --stat option adds diffstat(1) graph to the output. These
1649 options can be combined with other options, such as -p, and are meant
1650 for human consumption.
1651
1652 When showing a change that involves a rename or a copy, --stat output
1653 formats the pathnames compactly by combining common prefix and suffix
1654 of the pathnames. For example, a change that moves arch/i386/Makefile
1655 to arch/x86/Makefile while modifying 4 lines will be shown like this:
1656
1657 arch/{i386 => x86}/Makefile | 4 +--
1658
1659 The --numstat option gives the diffstat(1) information but is designed
1660 for easier machine consumption. An entry in --numstat output looks like
1661 this:
1662
1663 1 2 README
1664 3 1 arch/{i386 => x86}/Makefile
1665
1666 That is, from left to right:
1667
1668 1. the number of added lines;
1669
1670 2. a tab;
1671
1672 3. the number of deleted lines;
1673
1674 4. a tab;
1675
1676 5. pathname (possibly with rename/copy information);
1677
1678 6. a newline.
1679
1680 When -z output option is in effect, the output is formatted this way:
1681
1682 1 2 README NUL
1683 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
1684
1685 That is:
1686
1687 1. the number of added lines;
1688
1689 2. a tab;
1690
1691 3. the number of deleted lines;
1692
1693 4. a tab;
1694
1695 5. a NUL (only exists if renamed/copied);
1696
1697 6. pathname in preimage;
1698
1699 7. a NUL (only exists if renamed/copied);
1700
1701 8. pathname in postimage (only exists if renamed/copied);
1702
1703 9. a NUL.
1704
1705 The extra NUL before the preimage path in renamed case is to allow
1706 scripts that read the output to tell if the current record being read
1707 is a single-path record or a rename/copy record without reading ahead.
1708 After reading added and deleted lines, reading up to NUL would yield
1709 the pathname, but if that is NUL, the record will show two paths.
1710
1712 Part of the git(1) suite
1713
1714
1715
1716Git 2.31.1 2021-03-26 GIT-DIFF-TREE(1)