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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

25       -p, -u, --patch
26           Generate patch (see section on generating patches).
27
28       -U<n>, --unified=<n>
29           Generate diffs with <n> lines of context instead of the usual
30           three. Implies -p.
31
32       --raw
33           Generate the raw format. This is the default.
34
35       --patch-with-raw
36           Synonym for -p --raw.
37
38       --minimal
39           Spend extra time to make sure the smallest possible diff is
40           produced.
41
42       --patience
43           Generate a diff using the "patience diff" algorithm.
44
45       --histogram
46           Generate a diff using the "histogram diff" algorithm.
47
48       --diff-algorithm={patience|minimal|histogram|myers}
49           Choose a diff algorithm. The variants are as follows:
50
51           default, myers
52               The basic greedy diff algorithm. Currently, this is the
53               default.
54
55           minimal
56               Spend extra time to make sure the smallest possible diff is
57               produced.
58
59           patience
60               Use "patience diff" algorithm when generating patches.
61
62           histogram
63               This algorithm extends the patience algorithm to "support
64               low-occurrence common elements".
65
66           For instance, if you configured diff.algorithm variable to a
67           non-default value and want to use the default one, then you have to
68           use --diff-algorithm=default option.
69
70       --stat[=<width>[,<name-width>[,<count>]]]
71           Generate a diffstat. By default, as much space as necessary will be
72           used for the filename part, and the rest for the graph part.
73           Maximum width defaults to terminal width, or 80 columns if not
74           connected to a terminal, and can be overridden by <width>. The
75           width of the filename part can be limited by giving another width
76           <name-width> after a comma. The width of the graph part can be
77           limited by using --stat-graph-width=<width> (affects all commands
78           generating a stat graph) or by setting diff.statGraphWidth=<width>
79           (does not affect git format-patch). By giving a third parameter
80           <count>, you can limit the output to the first <count> lines,
81           followed by ...  if there are more.
82
83           These parameters can also be set individually with
84           --stat-width=<width>, --stat-name-width=<name-width> and
85           --stat-count=<count>.
86
87       --numstat
88           Similar to --stat, but shows number of added and deleted lines in
89           decimal notation and pathname without abbreviation, to make it more
90           machine friendly. For binary files, outputs two - instead of saying
91           0 0.
92
93       --shortstat
94           Output only the last line of the --stat format containing total
95           number of modified files, as well as number of added and deleted
96           lines.
97
98       --dirstat[=<param1,param2,...>]
99           Output the distribution of relative amount of changes for each
100           sub-directory. The behavior of --dirstat can be customized by
101           passing it a comma separated list of parameters. The defaults are
102           controlled by the diff.dirstat configuration variable (see git-
103           config(1)). The following parameters are available:
104
105           changes
106               Compute the dirstat numbers by counting the lines that have
107               been removed from the source, or added to the destination. This
108               ignores the amount of pure code movements within a file. In
109               other words, rearranging lines in a file is not counted as much
110               as other changes. This is the default behavior when no
111               parameter is given.
112
113           lines
114               Compute the dirstat numbers by doing the regular line-based
115               diff analysis, and summing the removed/added line counts. (For
116               binary files, count 64-byte chunks instead, since binary files
117               have no natural concept of lines). This is a more expensive
118               --dirstat behavior than the changes behavior, but it does count
119               rearranged lines within a file as much as other changes. The
120               resulting output is consistent with what you get from the other
121               --*stat options.
122
123           files
124               Compute the dirstat numbers by counting the number of files
125               changed. Each changed file counts equally in the dirstat
126               analysis. This is the computationally cheapest --dirstat
127               behavior, since it does not have to look at the file contents
128               at all.
129
130           cumulative
131               Count changes in a child directory for the parent directory as
132               well. Note that when using cumulative, the sum of the
133               percentages reported may exceed 100%. The default
134               (non-cumulative) behavior can be specified with the
135               noncumulative parameter.
136
137           <limit>
138               An integer parameter specifies a cut-off percent (3% by
139               default). Directories contributing less than this percentage of
140               the changes are not shown in the output.
141
142           Example: The following will count changed files, while ignoring
143           directories with less than 10% of the total amount of changed
144           files, and accumulating child directory counts in the parent
145           directories: --dirstat=files,10,cumulative.
146
147       --summary
148           Output a condensed summary of extended header information such as
149           creations, renames and mode changes.
150
151       --patch-with-stat
152           Synonym for -p --stat.
153
154       -z
155           When --raw, --numstat, --name-only or --name-status has been given,
156           do not munge pathnames and use NULs as output field terminators.
157
158           Without this option, each pathname output will have TAB, LF, double
159           quotes, and backslash characters replaced with \t, \n, \", and \\,
160           respectively, and the pathname will be enclosed in double quotes if
161           any of those replacements occurred.
162
163       --name-only
164           Show only names of changed files.
165
166       --name-status
167           Show only names and status of changed files. See the description of
168           the --diff-filter option on what the status letters mean.
169
170       --submodule[=<format>]
171           Specify how differences in submodules are shown. When --submodule
172           or --submodule=log is given, the log format is used. This format
173           lists the commits in the range like git-submodule(1)summary does.
174           Omitting the --submodule option or specifying --submodule=short,
175           uses the short format. This format just shows the names of the
176           commits at the beginning and end of the range. Can be tweaked via
177           the diff.submodule configuration variable.
178
179       --color[=<when>]
180           Show colored diff.  --color (i.e. without =<when>) is the same as
181           --color=always.  <when> can be one of always, never, or auto.
182
183       --no-color
184           Turn off colored diff. It is the same as --color=never.
185
186       --word-diff[=<mode>]
187           Show a word diff, using the <mode> to delimit changed words. By
188           default, words are delimited by whitespace; see --word-diff-regex
189           below. The <mode> defaults to plain, and must be one of:
190
191           color
192               Highlight changed words using only colors. Implies --color.
193
194           plain
195               Show words as [-removed-] and {+added+}. Makes no attempts to
196               escape the delimiters if they appear in the input, so the
197               output may be ambiguous.
198
199           porcelain
200               Use a special line-based format intended for script
201               consumption. Added/removed/unchanged runs are printed in the
202               usual unified diff format, starting with a +/-/` ` character at
203               the beginning of the line and extending to the end of the line.
204               Newlines in the input are represented by a tilde ~ on a line of
205               its own.
206
207           none
208               Disable word diff again.
209
210           Note that despite the name of the first mode, color is used to
211           highlight the changed parts in all modes if enabled.
212
213       --word-diff-regex=<regex>
214           Use <regex> to decide what a word is, instead of considering runs
215           of non-whitespace to be a word. Also implies --word-diff unless it
216           was already enabled.
217
218           Every non-overlapping match of the <regex> is considered a word.
219           Anything between these matches is considered whitespace and
220           ignored(!) for the purposes of finding differences. You may want to
221           append |[^[:space:]] to your regular expression to make sure that
222           it matches all non-whitespace characters. A match that contains a
223           newline is silently truncated(!) at the newline.
224
225           The regex can also be set via a diff driver or configuration
226           option, see gitattributes(1) or git-config(1). Giving it explicitly
227           overrides any diff driver or configuration setting. Diff drivers
228           override configuration settings.
229
230       --color-words[=<regex>]
231           Equivalent to --word-diff=color plus (if a regex was specified)
232           --word-diff-regex=<regex>.
233
234       --no-renames
235           Turn off rename detection, even when the configuration file gives
236           the default to do so.
237
238       --check
239           Warn if changes introduce whitespace errors. What are considered
240           whitespace errors is controlled by core.whitespace configuration.
241           By default, trailing whitespaces (including lines that solely
242           consist of whitespaces) and a space character that is immediately
243           followed by a tab character inside the initial indent of the line
244           are considered whitespace errors. Exits with non-zero status if
245           problems are found. Not compatible with --exit-code.
246
247       --full-index
248           Instead of the first handful of characters, show the full pre- and
249           post-image blob object names on the "index" line when generating
250           patch format output.
251
252       --binary
253           In addition to --full-index, output a binary diff that can be
254           applied with git-apply.
255
256       --abbrev[=<n>]
257           Instead of showing the full 40-byte hexadecimal object name in
258           diff-raw format output and diff-tree header lines, show only a
259           partial prefix. This is independent of the --full-index option
260           above, which controls the diff-patch output format. Non default
261           number of digits can be specified with --abbrev=<n>.
262
263       -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
264           Break complete rewrite changes into pairs of delete and create.
265           This serves two purposes:
266
267           It affects the way a change that amounts to a total rewrite of a
268           file not as a series of deletion and insertion mixed together with
269           a very few lines that happen to match textually as the context, but
270           as a single deletion of everything old followed by a single
271           insertion of everything new, and the number m controls this aspect
272           of the -B option (defaults to 60%).  -B/70% specifies that less
273           than 30% of the original should remain in the result for Git to
274           consider it a total rewrite (i.e. otherwise the resulting patch
275           will be a series of deletion and insertion mixed together with
276           context lines).
277
278           When used with -M, a totally-rewritten file is also considered as
279           the source of a rename (usually -M only considers a file that
280           disappeared as the source of a rename), and the number n controls
281           this aspect of the -B option (defaults to 50%).  -B20% specifies
282           that a change with addition and deletion compared to 20% or more of
283           the file’s size are eligible for being picked up as a possible
284           source of a rename to another file.
285
286       -M[<n>], --find-renames[=<n>]
287           Detect renames. If n is specified, it is a threshold on the
288           similarity index (i.e. amount of addition/deletions compared to the
289           file’s size). For example, -M90% means Git should consider a
290           delete/add pair to be a rename if more than 90% of the file hasn’t
291           changed. Without a % sign, the number is to be read as a fraction,
292           with a decimal point before it. I.e., -M5 becomes 0.5, and is thus
293           the same as -M50%. Similarly, -M05 is the same as -M5%. To limit
294           detection to exact renames, use -M100%.
295
296       -C[<n>], --find-copies[=<n>]
297           Detect copies as well as renames. See also --find-copies-harder. If
298           n is specified, it has the same meaning as for -M<n>.
299
300       --find-copies-harder
301           For performance reasons, by default, -C option finds copies only if
302           the original file of the copy was modified in the same changeset.
303           This flag makes the command inspect unmodified files as candidates
304           for the source of copy. This is a very expensive operation for
305           large projects, so use it with caution. Giving more than one -C
306           option has the same effect.
307
308       -D, --irreversible-delete
309           Omit the preimage for deletes, i.e. print only the header but not
310           the diff between the preimage and /dev/null. The resulting patch is
311           not meant to be applied with patch nor git apply; this is solely
312           for people who want to just concentrate on reviewing the text after
313           the change. In addition, the output obviously lack enough
314           information to apply such a patch in reverse, even manually, hence
315           the name of the option.
316
317           When used together with -B, omit also the preimage in the deletion
318           part of a delete/create pair.
319
320       -l<num>
321           The -M and -C options require O(n^2) processing time where n is the
322           number of potential rename/copy targets. This option prevents
323           rename/copy detection from running if the number of rename/copy
324           targets exceeds the specified number.
325
326       --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
327           Select only files that are Added (A), Copied (C), Deleted (D),
328           Modified (M), Renamed (R), have their type (i.e. regular file,
329           symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
330           (X), or have had their pairing Broken (B). Any combination of the
331           filter characters (including none) can be used. When *
332           (All-or-none) is added to the combination, all paths are selected
333           if there is any file that matches other criteria in the comparison;
334           if there is no file that matches other criteria, nothing is
335           selected.
336
337       -S<string>
338           Look for differences that introduce or remove an instance of
339           <string>. Note that this is different than the string simply
340           appearing in diff output; see the pickaxe entry in gitdiffcore(7)
341           for more details.
342
343       -G<regex>
344           Look for differences whose added or removed line matches the given
345           <regex>.
346
347       --pickaxe-all
348           When -S or -G finds a change, show all the changes in that
349           changeset, not just the files that contain the change in <string>.
350
351       --pickaxe-regex
352           Make the <string> not a plain string but an extended POSIX regex to
353           match.
354
355       -O<orderfile>
356           Output the patch in the order specified in the <orderfile>, which
357           has one shell glob pattern per line.
358
359       -R
360           Swap two inputs; that is, show differences from index or on-disk
361           file to tree contents.
362
363       --relative[=<path>]
364           When run from a subdirectory of the project, it can be told to
365           exclude changes outside the directory and show pathnames relative
366           to it with this option. When you are not in a subdirectory (e.g. in
367           a bare repository), you can name which subdirectory to make the
368           output relative to by giving a <path> as an argument.
369
370       -a, --text
371           Treat all files as text.
372
373       --ignore-space-at-eol
374           Ignore changes in whitespace at EOL.
375
376       -b, --ignore-space-change
377           Ignore changes in amount of whitespace. This ignores whitespace at
378           line end, and considers all other sequences of one or more
379           whitespace characters to be equivalent.
380
381       -w, --ignore-all-space
382           Ignore whitespace when comparing lines. This ignores differences
383           even if one line has whitespace where the other line has none.
384
385       --inter-hunk-context=<lines>
386           Show the context between diff hunks, up to the specified number of
387           lines, thereby fusing hunks that are close to each other.
388
389       -W, --function-context
390           Show whole surrounding functions of changes.
391
392       --exit-code
393           Make the program exit with codes similar to diff(1). That is, it
394           exits with 1 if there were differences and 0 means no differences.
395
396       --quiet
397           Disable all output of the program. Implies --exit-code.
398
399       --ext-diff
400           Allow an external diff helper to be executed. If you set an
401           external diff driver with gitattributes(5), you need to use this
402           option with git-log(1) and friends.
403
404       --no-ext-diff
405           Disallow external diff drivers.
406
407       --textconv, --no-textconv
408           Allow (or disallow) external text conversion filters to be run when
409           comparing binary files. See gitattributes(5) for details. Because
410           textconv filters are typically a one-way conversion, the resulting
411           diff is suitable for human consumption, but cannot be applied. For
412           this reason, textconv filters are enabled by default only for git-
413           diff(1) and git-log(1), but not for git-format-patch(1) or diff
414           plumbing commands.
415
416       --ignore-submodules[=<when>]
417           Ignore changes to submodules in the diff generation. <when> can be
418           either "none", "untracked", "dirty" or "all", which is the default.
419           Using "none" will consider the submodule modified when it either
420           contains untracked or modified files or its HEAD differs from the
421           commit recorded in the superproject and can be used to override any
422           settings of the ignore option in git-config(1) or gitmodules(5).
423           When "untracked" is used submodules are not considered dirty when
424           they only contain untracked content (but they are still scanned for
425           modified content). Using "dirty" ignores all changes to the work
426           tree of submodules, only changes to the commits stored in the
427           superproject are shown (this was the behavior until 1.7.0). Using
428           "all" hides all changes to submodules.
429
430       --src-prefix=<prefix>
431           Show the given source prefix instead of "a/".
432
433       --dst-prefix=<prefix>
434           Show the given destination prefix instead of "b/".
435
436       --no-prefix
437           Do not show any source or destination prefix.
438
439       For more detailed explanation on these common options, see also
440       gitdiffcore(7).
441
442       <tree-ish>
443           The id of a tree object.
444
445       <path>...
446           If provided, the results are limited to a subset of files matching
447           one of these prefix strings. i.e., file matches
448           /^<pattern1>|<pattern2>|.../ Note that this parameter does not
449           provide any wildcard or regexp features.
450
451       -r
452           recurse into sub-trees
453
454       -t
455           show tree entry itself as well as subtrees. Implies -r.
456
457       --root
458           When --root is specified the initial commit will be shown as a big
459           creation event. This is equivalent to a diff against the NULL tree.
460
461       --stdin
462           When --stdin is specified, the command does not take <tree-ish>
463           arguments from the command line. Instead, it reads lines containing
464           either two <tree>, one <commit>, or a list of <commit> from its
465           standard input. (Use a single space as separator.)
466
467           When two trees are given, it compares the first tree with the
468           second. When a single commit is given, it compares the commit with
469           its parents. The remaining commits, when given, are used as if they
470           are parents of the first commit.
471
472           When comparing two trees, the ID of both trees (separated by a
473           space and terminated by a newline) is printed before the
474           difference. When comparing commits, the ID of the first (or only)
475           commit, followed by a newline, is printed.
476
477           The following flags further affect the behavior when comparing
478           commits (but not trees).
479
480       -m
481           By default, git diff-tree --stdin does not show differences for
482           merge commits. With this flag, it shows differences to that commit
483           from all of its parents. See also -c.
484
485       -s
486           By default, git diff-tree --stdin shows differences, either in
487           machine-readable form (without -p) or in patch form (with -p). This
488           output can be suppressed. It is only useful with -v flag.
489
490       -v
491           This flag causes git diff-tree --stdin to also show the commit
492           message before the differences.
493
494       --pretty[=<format>], --format=<format>
495           Pretty-print the contents of the commit logs in a given format,
496           where <format> can be one of oneline, short, medium, full, fuller,
497           email, raw and format:<string>. See the "PRETTY FORMATS" section
498           for some additional details for each format. When omitted, the
499           format defaults to medium.
500
501           Note: you can specify the default pretty format in the repository
502           configuration (see git-config(1)).
503
504       --abbrev-commit
505           Instead of showing the full 40-byte hexadecimal commit object name,
506           show only a partial prefix. Non default number of digits can be
507           specified with "--abbrev=<n>" (which also modifies diff output, if
508           it is displayed).
509
510           This should make "--pretty=oneline" a whole lot more readable for
511           people using 80-column terminals.
512
513       --no-abbrev-commit
514           Show the full 40-byte hexadecimal commit object name. This negates
515           --abbrev-commit and those options which imply it such as
516           "--oneline". It also overrides the log.abbrevCommit variable.
517
518       --oneline
519           This is a shorthand for "--pretty=oneline --abbrev-commit" used
520           together.
521
522       --encoding[=<encoding>]
523           The commit objects record the encoding used for the log message in
524           their encoding header; this option can be used to tell the command
525           to re-code the commit log message in the encoding preferred by the
526           user. For non plumbing commands this defaults to UTF-8.
527
528       --notes[=<ref>]
529           Show the notes (see git-notes(1)) that annotate the commit, when
530           showing the commit log message. This is the default for git log,
531           git show and git whatchanged commands when there is no --pretty,
532           --format nor --oneline option given on the command line.
533
534           By default, the notes shown are from the notes refs listed in the
535           core.notesRef and notes.displayRef variables (or corresponding
536           environment overrides). See git-config(1) for more details.
537
538           With an optional <ref> argument, show this notes ref instead of the
539           default notes ref(s). The ref is taken to be in refs/notes/ if it
540           is not qualified.
541
542           Multiple --notes options can be combined to control which notes are
543           being displayed. Examples: "--notes=foo" will show only notes from
544           "refs/notes/foo"; "--notes=foo --notes" will show both notes from
545           "refs/notes/foo" and from the default notes ref(s).
546
547       --no-notes
548           Do not show notes. This negates the above --notes option, by
549           resetting the list of notes refs from which notes are shown.
550           Options are parsed in the order given on the command line, so e.g.
551           "--notes --notes=foo --no-notes --notes=bar" will only show notes
552           from "refs/notes/bar".
553
554       --show-notes[=<ref>], --[no-]standard-notes
555           These options are deprecated. Use the above --notes/--no-notes
556           options instead.
557
558       --show-signature
559           Check the validity of a signed commit object by passing the
560           signature to gpg --verify and show the output.
561
562       --no-commit-id
563           git diff-tree outputs a line with the commit ID when applicable.
564           This flag suppressed the commit ID output.
565
566       -c
567           This flag changes the way a merge commit is displayed (which means
568           it is useful only when the command is given one <tree-ish>, or
569           --stdin). It shows the differences from each of the parents to the
570           merge result simultaneously instead of showing pairwise diff
571           between a parent and the result one at a time (which is what the -m
572           option does). Furthermore, it lists only files which were modified
573           from all parents.
574
575       --cc
576           This flag changes the way a merge commit patch is displayed, in a
577           similar way to the -c option. It implies the -c and -p options and
578           further compresses the patch output by omitting uninteresting hunks
579           whose the contents in the parents have only two variants and the
580           merge result picks one of them without modification. When all hunks
581           are uninteresting, the commit itself and the commit log message is
582           not shown, just like in any other "empty diff" case.
583
584       --always
585           Show the commit itself and the commit log message even if the diff
586           itself is empty.
587

PRETTY FORMATS

589       If the commit is a merge, and if the pretty-format is not oneline,
590       email or raw, an additional line is inserted before the Author: line.
591       This line begins with "Merge: " and the sha1s of ancestral commits are
592       printed, separated by spaces. Note that the listed commits may not
593       necessarily be the list of the direct parent commits if you have
594       limited your view of history: for example, if you are only interested
595       in changes related to a certain directory or file.
596
597       There are several built-in formats, and you can define additional
598       formats by setting a pretty.<name> config option to either another
599       format name, or a format: string, as described below (see git-
600       config(1)). Here are the details of the built-in formats:
601
602       ·   oneline
603
604               <sha1> <title line>
605
606           This is designed to be as compact as possible.
607
608       ·   short
609
610               commit <sha1>
611               Author: <author>
612
613               <title line>
614
615       ·   medium
616
617               commit <sha1>
618               Author: <author>
619               Date:   <author date>
620
621               <title line>
622
623               <full commit message>
624
625       ·   full
626
627               commit <sha1>
628               Author: <author>
629               Commit: <committer>
630
631               <title line>
632
633               <full commit message>
634
635       ·   fuller
636
637               commit <sha1>
638               Author:     <author>
639               AuthorDate: <author date>
640               Commit:     <committer>
641               CommitDate: <committer date>
642
643               <title line>
644
645               <full commit message>
646
647       ·   email
648
649               From <sha1> <date>
650               From: <author>
651               Date: <author date>
652               Subject: [PATCH] <title line>
653
654               <full commit message>
655
656       ·   raw
657
658           The raw format shows the entire commit exactly as stored in the
659           commit object. Notably, the SHA-1s are displayed in full,
660           regardless of whether --abbrev or --no-abbrev are used, and parents
661           information show the true parent commits, without taking grafts nor
662           history simplification into account.
663
664       ·   format:<string>
665
666           The format:<string> format allows you to specify which information
667           you want to show. It works a little bit like printf format, with
668           the notable exception that you get a newline with %n instead of \n.
669
670           E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
671           would show something like this:
672
673               The author of fe6e0ee was Junio C Hamano, 23 hours ago
674               The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
675
676           The placeholders are:
677
678           ·   %H: commit hash
679
680           ·   %h: abbreviated commit hash
681
682           ·   %T: tree hash
683
684           ·   %t: abbreviated tree hash
685
686           ·   %P: parent hashes
687
688           ·   %p: abbreviated parent hashes
689
690           ·   %an: author name
691
692           ·   %aN: author name (respecting .mailmap, see git-shortlog(1) or
693               git-blame(1))
694
695           ·   %ae: author email
696
697           ·   %aE: author email (respecting .mailmap, see git-shortlog(1) or
698               git-blame(1))
699
700           ·   %ad: author date (format respects --date= option)
701
702           ·   %aD: author date, RFC2822 style
703
704           ·   %ar: author date, relative
705
706           ·   %at: author date, UNIX timestamp
707
708           ·   %ai: author date, ISO 8601 format
709
710           ·   %cn: committer name
711
712           ·   %cN: committer name (respecting .mailmap, see git-shortlog(1)
713               or git-blame(1))
714
715           ·   %ce: committer email
716
717           ·   %cE: committer email (respecting .mailmap, see git-shortlog(1)
718               or git-blame(1))
719
720           ·   %cd: committer date
721
722           ·   %cD: committer date, RFC2822 style
723
724           ·   %cr: committer date, relative
725
726           ·   %ct: committer date, UNIX timestamp
727
728           ·   %ci: committer date, ISO 8601 format
729
730           ·   %d: ref names, like the --decorate option of git-log(1)
731
732           ·   %e: encoding
733
734           ·   %s: subject
735
736           ·   %f: sanitized subject line, suitable for a filename
737
738           ·   %b: body
739
740           ·   %B: raw body (unwrapped subject and body)
741
742           ·   %N: commit notes
743
744           ·   %GG: raw verification message from GPG for a signed commit
745
746           ·   %G?: show "G" for a Good signature, "B" for a Bad signature,
747               "U" for a good, untrusted signature and "N" for no signature
748
749           ·   %GS: show the name of the signer for a signed commit
750
751           ·   %GK: show the key used to sign a signed commit
752
753           ·   %gD: reflog selector, e.g., refs/stash@{1}
754
755           ·   %gd: shortened reflog selector, e.g., stash@{1}
756
757           ·   %gn: reflog identity name
758
759           ·   %gN: reflog identity name (respecting .mailmap, see git-
760               shortlog(1) or git-blame(1))
761
762           ·   %ge: reflog identity email
763
764           ·   %gE: reflog identity email (respecting .mailmap, see git-
765               shortlog(1) or git-blame(1))
766
767           ·   %gs: reflog subject
768
769           ·   %Cred: switch color to red
770
771           ·   %Cgreen: switch color to green
772
773           ·   %Cblue: switch color to blue
774
775           ·   %Creset: reset color
776
777           ·   %C(...): color specification, as described in color.branch.*
778               config option; adding auto, at the beginning will emit color
779               only when colors are enabled for log output (by color.diff,
780               color.ui, or --color, and respecting the auto settings of the
781               former if we are going to a terminal).  auto alone (i.e.
782               %C(auto)) will turn on auto coloring on the next placeholders
783               until the color is switched again.
784
785           ·   %m: left, right or boundary mark
786
787           ·   %n: newline
788
789           ·   %%: a raw %
790
791           ·   %x00: print a byte from a hex code
792
793           ·   %w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w
794               option of git-shortlog(1).
795
796           ·   %<(<N>[,trunc|ltrunc|mtrunc]): make the next placeholder take
797               at least N columns, padding spaces on the right if necessary.
798               Optionally truncate at the beginning (ltrunc), the middle
799               (mtrunc) or the end (trunc) if the output is longer than N
800               columns. Note that truncating only works correctly with N >= 2.
801
802           ·   %<|(<N>): make the next placeholder take at least until Nth
803               columns, padding spaces on the right if necessary
804
805           ·   %>(<N>), %>|(<N>): similar to %<(<N>), %<|(<N>) respectively,
806               but padding spaces on the left
807
808           ·   %>>(<N>), %>>|(<N>): similar to %>(<N>), %>|(<N>) respectively,
809               except that if the next placeholder takes more spaces than
810               given and there are spaces on its left, use those spaces
811
812           ·   %><(<N>), %><|(<N>): similar to % <(<N>), %<|(<N>)
813               respectively, but padding both sides (i.e. the text is
814               centered)
815
816           Note
817           Some placeholders may depend on other options given to the revision
818           traversal engine. For example, the %g* reflog options will insert
819           an empty string unless we are traversing reflog entries (e.g., by
820           git log -g). The %d placeholder will use the "short" decoration
821           format if --decorate was not already provided on the command line.
822
823       If you add a + (plus sign) after % of a placeholder, a line-feed is
824       inserted immediately before the expansion if and only if the
825       placeholder expands to a non-empty string.
826
827       If you add a - (minus sign) after % of a placeholder, line-feeds that
828       immediately precede the expansion are deleted if and only if the
829       placeholder expands to an empty string.
830
831       If you add a ` ` (space) after % of a placeholder, a space is inserted
832       immediately before the expansion if and only if the placeholder expands
833       to a non-empty string.
834
835       ·   tformat:
836
837           The tformat: format works exactly like format:, except that it
838           provides "terminator" semantics instead of "separator" semantics.
839           In other words, each commit has the message terminator character
840           (usually a newline) appended, rather than a separator placed
841           between entries. This means that the final entry of a single-line
842           format will be properly terminated with a new line, just as the
843           "oneline" format does. For example:
844
845               $ git log -2 --pretty=format:%h 4da45bef \
846                 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
847               4da45be
848               7134973 -- NO NEWLINE
849
850               $ git log -2 --pretty=tformat:%h 4da45bef \
851                 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
852               4da45be
853               7134973
854
855           In addition, any unrecognized string that has a % in it is
856           interpreted as if it has tformat: in front of it. For example,
857           these two are equivalent:
858
859               $ git log -2 --pretty=tformat:%h 4da45bef
860               $ git log -2 --pretty=%h 4da45bef
861
862

LIMITING OUTPUT

864       If you’re only interested in differences in a subset of files, for
865       example some architecture-specific files, you might do:
866
867           git diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64
868
869       and it will only show you what changed in those two directories.
870
871       Or if you are searching for what changed in just kernel/sched.c, just
872       do
873
874           git diff-tree -r <tree-ish> <tree-ish> kernel/sched.c
875
876       and it will ignore all differences to other files.
877
878       The pattern is always the prefix, and is matched exactly. There are no
879       wildcards. Even stricter, it has to match a complete path component.
880       I.e. "foo" does not pick up foobar.h. "foo" does match foo/bar.h so it
881       can be used to name subdirectories.
882
883       An example of normal usage is:
884
885           torvalds@ppc970:~/git> git diff-tree --abbrev 5319e4
886           :100664 100664 ac348b... a01513...    git-fsck-objects.c
887
888       which tells you that the last commit changed just one file (it’s from
889       this one:
890
891           commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
892           tree 5319e4d609cdd282069cc4dce33c1db559539b03
893           parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
894           author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
895           committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
896
897           Make "git-fsck-objects" print out all the root commits it finds.
898
899           Once I do the reference tracking, I'll also make it print out all the
900           HEAD commits it finds, which is even more interesting.
901
902
903       in case you care).
904

RAW OUTPUT FORMAT

906       The raw output format from "git-diff-index", "git-diff-tree",
907       "git-diff-files" and "git diff --raw" are very similar.
908
909       These commands all compare two sets of things; what is compared
910       differs:
911
912       git-diff-index <tree-ish>
913           compares the <tree-ish> and the files on the filesystem.
914
915       git-diff-index --cached <tree-ish>
916           compares the <tree-ish> and the index.
917
918       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
919           compares the trees named by the two arguments.
920
921       git-diff-files [<pattern>...]
922           compares the index and the files on the filesystem.
923
924       The "git-diff-tree" command begins its output by printing the hash of
925       what is being compared. After that, all the commands print one output
926       line per changed file.
927
928       An output line is formatted this way:
929
930           in-place edit  :100644 100644 bcd1234... 0123456... M file0
931           copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
932           rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
933           create         :000000 100644 0000000... 1234567... A file4
934           delete         :100644 000000 1234567... 0000000... D file5
935           unmerged       :000000 000000 0000000... 0000000... U file6
936
937
938       That is, from the left to the right:
939
940        1. a colon.
941
942        2. mode for "src"; 000000 if creation or unmerged.
943
944        3. a space.
945
946        4. mode for "dst"; 000000 if deletion or unmerged.
947
948        5. a space.
949
950        6. sha1 for "src"; 0{40} if creation or unmerged.
951
952        7. a space.
953
954        8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
955
956        9. a space.
957
958       10. status, followed by optional "score" number.
959
960       11. a tab or a NUL when -z option is used.
961
962       12. path for "src"
963
964       13. a tab or a NUL when -z option is used; only exists for C or R.
965
966       14. path for "dst"; only exists for C or R.
967
968       15. an LF or a NUL when -z option is used, to terminate the record.
969
970       Possible status letters are:
971
972       ·   A: addition of a file
973
974       ·   C: copy of a file into a new one
975
976       ·   D: deletion of a file
977
978       ·   M: modification of the contents or mode of a file
979
980       ·   R: renaming of a file
981
982       ·   T: change in the type of the file
983
984       ·   U: file is unmerged (you must complete the merge before it can be
985           committed)
986
987       ·   X: "unknown" change type (most probably a bug, please report it)
988
989       Status letters C and R are always followed by a score (denoting the
990       percentage of similarity between the source and target of the move or
991       copy), and are the only ones to be so.
992
993       <sha1> is shown as all 0’s if a file is new on the filesystem and it is
994       out of sync with the index.
995
996       Example:
997
998           :100644 100644 5be4a4...... 000000...... M file.c
999
1000
1001       When -z option is not used, TAB, LF, and backslash characters in
1002       pathnames are represented as \t, \n, and \\, respectively.
1003

DIFF FORMAT FOR MERGES

1005       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
1006       --cc option to generate diff output also for merge commits. The output
1007       differs from the format described above in the following way:
1008
1009        1. there is a colon for each parent
1010
1011        2. there are more "src" modes and "src" sha1
1012
1013        3. status is concatenated status characters for each parent
1014
1015        4. no optional "score" number
1016
1017        5. single path, only for "dst"
1018
1019       Example:
1020
1021           ::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM      describe.c
1022
1023
1024       Note that combined diff lists only files which were modified from all
1025       parents.
1026

GENERATING PATCHES WITH -P

1028       When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1029       with a -p option, "git diff" without the --raw option, or "git log"
1030       with the "-p" option, they do not produce the output described above;
1031       instead they produce a patch file. You can customize the creation of
1032       such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
1033       environment variables.
1034
1035       What the -p option produces is slightly different from the traditional
1036       diff format:
1037
1038        1. It is preceded with a "git diff" header that looks like this:
1039
1040               diff --git a/file1 b/file2
1041
1042           The a/ and b/ filenames are the same unless rename/copy is
1043           involved. Especially, even for a creation or a deletion, /dev/null
1044           is not used in place of the a/ or b/ filenames.
1045
1046           When rename/copy is involved, file1 and file2 show the name of the
1047           source file of the rename/copy and the name of the file that
1048           rename/copy produces, respectively.
1049
1050        2. It is followed by one or more extended header lines:
1051
1052               old mode <mode>
1053               new mode <mode>
1054               deleted file mode <mode>
1055               new file mode <mode>
1056               copy from <path>
1057               copy to <path>
1058               rename from <path>
1059               rename to <path>
1060               similarity index <number>
1061               dissimilarity index <number>
1062               index <hash>..<hash> <mode>
1063
1064           File modes are printed as 6-digit octal numbers including the file
1065           type and file permission bits.
1066
1067           Path names in extended headers do not include the a/ and b/
1068           prefixes.
1069
1070           The similarity index is the percentage of unchanged lines, and the
1071           dissimilarity index is the percentage of changed lines. It is a
1072           rounded down integer, followed by a percent sign. The similarity
1073           index value of 100% is thus reserved for two equal files, while
1074           100% dissimilarity means that no line from the old file made it
1075           into the new one.
1076
1077           The index line includes the SHA-1 checksum before and after the
1078           change. The <mode> is included if the file mode does not change;
1079           otherwise, separate lines indicate the old and the new mode.
1080
1081        3. TAB, LF, double quote and backslash characters in pathnames are
1082           represented as \t, \n, \" and \\, respectively. If there is need
1083           for such substitution then the whole pathname is put in double
1084           quotes.
1085
1086        4. All the file1 files in the output refer to files before the commit,
1087           and all the file2 files refer to files after the commit. It is
1088           incorrect to apply each change to each file sequentially. For
1089           example, this patch will swap a and b:
1090
1091               diff --git a/a b/b
1092               rename from a
1093               rename to b
1094               diff --git a/b b/a
1095               rename from b
1096               rename to a
1097

COMBINED DIFF FORMAT

1099       Any diff-generating command can take the ‘-c` or --cc option to produce
1100       a combined diff when showing a merge. This is the default format when
1101       showing merges with git-diff(1) or git-show(1). Note also that you can
1102       give the `-m’ option to any of these commands to force generation of
1103       diffs with individual parents of a merge.
1104
1105       A combined diff format looks like this:
1106
1107           diff --combined describe.c
1108           index fabadb8,cc95eb0..4866510
1109           --- a/describe.c
1110           +++ b/describe.c
1111           @@@ -98,20 -98,12 +98,20 @@@
1112                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1113             }
1114
1115           - static void describe(char *arg)
1116            -static void describe(struct commit *cmit, int last_one)
1117           ++static void describe(char *arg, int last_one)
1118             {
1119            +      unsigned char sha1[20];
1120            +      struct commit *cmit;
1121                   struct commit_list *list;
1122                   static int initialized = 0;
1123                   struct commit_name *n;
1124
1125            +      if (get_sha1(arg, sha1) < 0)
1126            +              usage(describe_usage);
1127            +      cmit = lookup_commit_reference(sha1);
1128            +      if (!cmit)
1129            +              usage(describe_usage);
1130            +
1131                   if (!initialized) {
1132                           initialized = 1;
1133                           for_each_ref(get_name);
1134
1135
1136
1137        1. It is preceded with a "git diff" header, that looks like this (when
1138           -c option is used):
1139
1140               diff --combined file
1141
1142           or like this (when --cc option is used):
1143
1144               diff --cc file
1145
1146        2. It is followed by one or more extended header lines (this example
1147           shows a merge with two parents):
1148
1149               index <hash>,<hash>..<hash>
1150               mode <mode>,<mode>..<mode>
1151               new file mode <mode>
1152               deleted file mode <mode>,<mode>
1153
1154           The mode <mode>,<mode>..<mode> line appears only if at least one of
1155           the <mode> is different from the rest. Extended headers with
1156           information about detected contents movement (renames and copying
1157           detection) are designed to work with diff of two <tree-ish> and are
1158           not used by combined diff format.
1159
1160        3. It is followed by two-line from-file/to-file header
1161
1162               --- a/file
1163               +++ b/file
1164
1165           Similar to two-line header for traditional unified diff format,
1166           /dev/null is used to signal created or deleted files.
1167
1168        4. Chunk header format is modified to prevent people from accidentally
1169           feeding it to patch -p1. Combined diff format was created for
1170           review of merge commit changes, and was not meant for apply. The
1171           change is similar to the change in the extended index header:
1172
1173               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
1174
1175           There are (number of parents + 1) @ characters in the chunk header
1176           for combined diff format.
1177
1178       Unlike the traditional unified diff format, which shows two files A and
1179       B with a single column that has - (minus — appears in A but removed in
1180       B), + (plus — missing in A but added to B), or " " (space — unchanged)
1181       prefix, this format compares two or more files file1, file2,... with
1182       one file X, and shows how X differs from each of fileN. One column for
1183       each of fileN is prepended to the output line to note how X’s line is
1184       different from it.
1185
1186       A - character in the column N means that the line appears in fileN but
1187       it does not appear in the result. A + character in the column N means
1188       that the line appears in the result, and fileN does not have that line
1189       (in other words, the line was added, from the point of view of that
1190       parent).
1191
1192       In the above example output, the function signature was changed from
1193       both files (hence two - removals from both file1 and file2, plus ++ to
1194       mean one line that was added does not appear in either file1 nor
1195       file2). Also eight other lines are the same from file1 but do not
1196       appear in file2 (hence prefixed with +).
1197
1198       When shown by git diff-tree -c, it compares the parents of a merge
1199       commit with the merge result (i.e. file1..fileN are the parents). When
1200       shown by git diff-files -c, it compares the two unresolved merge
1201       parents with the working tree file (i.e. file1 is stage 2 aka "our
1202       version", file2 is stage 3 aka "their version").
1203

OTHER DIFF FORMATS

1205       The --summary option describes newly added, deleted, renamed and copied
1206       files. The --stat option adds diffstat(1) graph to the output. These
1207       options can be combined with other options, such as -p, and are meant
1208       for human consumption.
1209
1210       When showing a change that involves a rename or a copy, --stat output
1211       formats the pathnames compactly by combining common prefix and suffix
1212       of the pathnames. For example, a change that moves arch/i386/Makefile
1213       to arch/x86/Makefile while modifying 4 lines will be shown like this:
1214
1215           arch/{i386 => x86}/Makefile    |   4 +--
1216
1217
1218       The --numstat option gives the diffstat(1) information but is designed
1219       for easier machine consumption. An entry in --numstat output looks like
1220       this:
1221
1222           1       2       README
1223           3       1       arch/{i386 => x86}/Makefile
1224
1225
1226       That is, from left to right:
1227
1228        1. the number of added lines;
1229
1230        2. a tab;
1231
1232        3. the number of deleted lines;
1233
1234        4. a tab;
1235
1236        5. pathname (possibly with rename/copy information);
1237
1238        6. a newline.
1239
1240       When -z output option is in effect, the output is formatted this way:
1241
1242           1       2       README NUL
1243           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
1244
1245
1246       That is:
1247
1248        1. the number of added lines;
1249
1250        2. a tab;
1251
1252        3. the number of deleted lines;
1253
1254        4. a tab;
1255
1256        5. a NUL (only exists if renamed/copied);
1257
1258        6. pathname in preimage;
1259
1260        7. a NUL (only exists if renamed/copied);
1261
1262        8. pathname in postimage (only exists if renamed/copied);
1263
1264        9. a NUL.
1265
1266       The extra NUL before the preimage path in renamed case is to allow
1267       scripts that read the output to tell if the current record being read
1268       is a single-path record or a rename/copy record without reading ahead.
1269       After reading added and deleted lines, reading up to NUL would yield
1270       the pathname, but if that is NUL, the record will show two paths.
1271

GIT

1273       Part of the git(1) suite
1274
1275
1276
1277Git 1.8.3.1                       11/19/2018                  GIT-DIFF-TREE(1)
Impressum