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