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

NAME

6       git-diff-files - Compares files in the working tree and the index
7

SYNOPSIS

9       git diff-files [-q] [-0|-1|-2|-3|-c|--cc] [<common diff options>] [<path>...]
10
11

DESCRIPTION

13       Compares the files in the working tree and the index. When paths are
14       specified, compares only those named paths. Otherwise all entries in
15       the index are compared. The output format is the same as for git
16       diff-index and git diff-tree.
17

OPTIONS

19       -p, -u, --patch
20           Generate patch (see section on generating patches).
21
22       -s, --no-patch
23           Suppress diff output. Useful for commands like git show that show
24           the patch by default, or to cancel the effect of --patch.
25
26       -U<n>, --unified=<n>
27           Generate diffs with <n> lines of context instead of the usual
28           three. Implies --patch. Implies -p.
29
30       --output=<file>
31           Output to a specific file instead of stdout.
32
33       --output-indicator-new=<char>, --output-indicator-old=<char>,
34       --output-indicator-context=<char>
35           Specify the character used to indicate new, old or context lines in
36           the generated patch. Normally they are +, - and ' ' respectively.
37
38       --raw
39           Generate the diff in raw format. This is the default.
40
41       --patch-with-raw
42           Synonym for -p --raw.
43
44       --indent-heuristic
45           Enable the heuristic that shifts diff hunk boundaries to make
46           patches easier to read. This is the default.
47
48       --no-indent-heuristic
49           Disable the indent heuristic.
50
51       --minimal
52           Spend extra time to make sure the smallest possible diff is
53           produced.
54
55       --patience
56           Generate a diff using the "patience diff" algorithm.
57
58       --histogram
59           Generate a diff using the "histogram diff" algorithm.
60
61       --anchored=<text>
62           Generate a diff using the "anchored diff" algorithm.
63
64           This option may be specified more than once.
65
66           If a line exists in both the source and destination, exists only
67           once, and starts with this text, this algorithm attempts to prevent
68           it from appearing as a deletion or addition in the output. It uses
69           the "patience diff" algorithm internally.
70
71       --diff-algorithm={patience|minimal|histogram|myers}
72           Choose a diff algorithm. The variants are as follows:
73
74           default, myers
75               The basic greedy diff algorithm. Currently, this is the
76               default.
77
78           minimal
79               Spend extra time to make sure the smallest possible diff is
80               produced.
81
82           patience
83               Use "patience diff" algorithm when generating patches.
84
85           histogram
86               This algorithm extends the patience algorithm to "support
87               low-occurrence common elements".
88
89           For instance, if you configured the diff.algorithm variable to a
90           non-default value and want to use the default one, then you have to
91           use --diff-algorithm=default option.
92
93       --stat[=<width>[,<name-width>[,<count>]]]
94           Generate a diffstat. By default, as much space as necessary will be
95           used for the filename part, and the rest for the graph part.
96           Maximum width defaults to terminal width, or 80 columns if not
97           connected to a terminal, and can be overridden by <width>. The
98           width of the filename part can be limited by giving another width
99           <name-width> after a comma. The width of the graph part can be
100           limited by using --stat-graph-width=<width> (affects all commands
101           generating a stat graph) or by setting diff.statGraphWidth=<width>
102           (does not affect git format-patch). By giving a third parameter
103           <count>, you can limit the output to the first <count> lines,
104           followed by ...  if there are more.
105
106           These parameters can also be set individually with
107           --stat-width=<width>, --stat-name-width=<name-width> and
108           --stat-count=<count>.
109
110       --compact-summary
111           Output a condensed summary of extended header information such as
112           file creations or deletions ("new" or "gone", optionally "+l" if
113           it’s a symlink) and mode changes ("+x" or "-x" for adding or
114           removing executable bit respectively) in diffstat. The information
115           is put between the filename part and the graph part. Implies
116           --stat.
117
118       --numstat
119           Similar to --stat, but shows number of added and deleted lines in
120           decimal notation and pathname without abbreviation, to make it more
121           machine friendly. For binary files, outputs two - instead of saying
122           0 0.
123
124       --shortstat
125           Output only the last line of the --stat format containing total
126           number of modified files, as well as number of added and deleted
127           lines.
128
129       -X[<param1,param2,...>], --dirstat[=<param1,param2,...>]
130           Output the distribution of relative amount of changes for each
131           sub-directory. The behavior of --dirstat can be customized by
132           passing it a comma separated list of parameters. The defaults are
133           controlled by the diff.dirstat configuration variable (see git-
134           config(1)). The following parameters are available:
135
136           changes
137               Compute the dirstat numbers by counting the lines that have
138               been removed from the source, or added to the destination. This
139               ignores the amount of pure code movements within a file. In
140               other words, rearranging lines in a file is not counted as much
141               as other changes. This is the default behavior when no
142               parameter is given.
143
144           lines
145               Compute the dirstat numbers by doing the regular line-based
146               diff analysis, and summing the removed/added line counts. (For
147               binary files, count 64-byte chunks instead, since binary files
148               have no natural concept of lines). This is a more expensive
149               --dirstat behavior than the changes behavior, but it does count
150               rearranged lines within a file as much as other changes. The
151               resulting output is consistent with what you get from the other
152               --*stat options.
153
154           files
155               Compute the dirstat numbers by counting the number of files
156               changed. Each changed file counts equally in the dirstat
157               analysis. This is the computationally cheapest --dirstat
158               behavior, since it does not have to look at the file contents
159               at all.
160
161           cumulative
162               Count changes in a child directory for the parent directory as
163               well. Note that when using cumulative, the sum of the
164               percentages reported may exceed 100%. The default
165               (non-cumulative) behavior can be specified with the
166               noncumulative parameter.
167
168           <limit>
169               An integer parameter specifies a cut-off percent (3% by
170               default). Directories contributing less than this percentage of
171               the changes are not shown in the output.
172
173           Example: The following will count changed files, while ignoring
174           directories with less than 10% of the total amount of changed
175           files, and accumulating child directory counts in the parent
176           directories: --dirstat=files,10,cumulative.
177
178       --cumulative
179           Synonym for --dirstat=cumulative
180
181       --dirstat-by-file[=<param1,param2>...]
182           Synonym for --dirstat=files,param1,param2...
183
184       --summary
185           Output a condensed summary of extended header information such as
186           creations, renames and mode changes.
187
188       --patch-with-stat
189           Synonym for -p --stat.
190
191       -z
192           When --raw, --numstat, --name-only or --name-status has been given,
193           do not munge pathnames and use NULs as output field terminators.
194
195           Without this option, pathnames with "unusual" characters are quoted
196           as explained for the configuration variable core.quotePath (see
197           git-config(1)).
198
199       --name-only
200           Show only names of changed files.
201
202       --name-status
203           Show only names and status of changed files. See the description of
204           the --diff-filter option on what the status letters mean.
205
206       --submodule[=<format>]
207           Specify how differences in submodules are shown. When specifying
208           --submodule=short the short format is used. This format just shows
209           the names of the commits at the beginning and end of the range.
210           When --submodule or --submodule=log is specified, the log format is
211           used. This format lists the commits in the range like git-
212           submodule(1) summary does. When --submodule=diff is specified, the
213           diff format is used. This format shows an inline diff of the
214           changes in the submodule contents between the commit range.
215           Defaults to diff.submodule or the short format if the config option
216           is unset.
217
218       --color[=<when>]
219           Show colored diff.  --color (i.e. without =<when>) is the same as
220           --color=always.  <when> can be one of always, never, or auto.
221
222       --no-color
223           Turn off colored diff. It is the same as --color=never.
224
225       --color-moved[=<mode>]
226           Moved lines of code are colored differently. The <mode> defaults to
227           no if the option is not given and to zebra if the option with no
228           mode is given. The mode must be one of:
229
230           no
231               Moved lines are not highlighted.
232
233           default
234               Is a synonym for zebra. This may change to a more sensible mode
235               in the future.
236
237           plain
238               Any line that is added in one location and was removed in
239               another location will be colored with color.diff.newMoved.
240               Similarly color.diff.oldMoved will be used for removed lines
241               that are added somewhere else in the diff. This mode picks up
242               any moved line, but it is not very useful in a review to
243               determine if a block of code was moved without permutation.
244
245           blocks
246               Blocks of moved text of at least 20 alphanumeric characters are
247               detected greedily. The detected blocks are painted using either
248               the color.diff.{old,new}Moved color. Adjacent blocks cannot be
249               told apart.
250
251           zebra
252               Blocks of moved text are detected as in blocks mode. The blocks
253               are painted using either the color.diff.{old,new}Moved color or
254               color.diff.{old,new}MovedAlternative. The change between the
255               two colors indicates that a new block was detected.
256
257           dimmed-zebra
258               Similar to zebra, but additional dimming of uninteresting parts
259               of moved code is performed. The bordering lines of two adjacent
260               blocks are considered interesting, the rest is uninteresting.
261               dimmed_zebra is a deprecated synonym.
262
263       --no-color-moved
264           Turn off move detection. This can be used to override configuration
265           settings. It is the same as --color-moved=no.
266
267       --color-moved-ws=<modes>
268           This configures how whitespace is ignored when performing the move
269           detection for --color-moved. These modes can be given as a comma
270           separated list:
271
272           no
273               Do not ignore whitespace when performing move detection.
274
275           ignore-space-at-eol
276               Ignore changes in whitespace at EOL.
277
278           ignore-space-change
279               Ignore changes in amount of whitespace. This ignores whitespace
280               at line end, and considers all other sequences of one or more
281               whitespace characters to be equivalent.
282
283           ignore-all-space
284               Ignore whitespace when comparing lines. This ignores
285               differences even if one line has whitespace where the other
286               line has none.
287
288           allow-indentation-change
289               Initially ignore any whitespace in the move detection, then
290               group the moved code blocks only into a block if the change in
291               whitespace is the same per line. This is incompatible with the
292               other modes.
293
294       --no-color-moved-ws
295           Do not ignore whitespace when performing move detection. This can
296           be used to override configuration settings. It is the same as
297           --color-moved-ws=no.
298
299       --word-diff[=<mode>]
300           Show a word diff, using the <mode> to delimit changed words. By
301           default, words are delimited by whitespace; see --word-diff-regex
302           below. The <mode> defaults to plain, and must be one of:
303
304           color
305               Highlight changed words using only colors. Implies --color.
306
307           plain
308               Show words as [-removed-] and {+added+}. Makes no attempts to
309               escape the delimiters if they appear in the input, so the
310               output may be ambiguous.
311
312           porcelain
313               Use a special line-based format intended for script
314               consumption. Added/removed/unchanged runs are printed in the
315               usual unified diff format, starting with a +/-/` ` character at
316               the beginning of the line and extending to the end of the line.
317               Newlines in the input are represented by a tilde ~ on a line of
318               its own.
319
320           none
321               Disable word diff again.
322
323           Note that despite the name of the first mode, color is used to
324           highlight the changed parts in all modes if enabled.
325
326       --word-diff-regex=<regex>
327           Use <regex> to decide what a word is, instead of considering runs
328           of non-whitespace to be a word. Also implies --word-diff unless it
329           was already enabled.
330
331           Every non-overlapping match of the <regex> is considered a word.
332           Anything between these matches is considered whitespace and
333           ignored(!) for the purposes of finding differences. You may want to
334           append |[^[:space:]] to your regular expression to make sure that
335           it matches all non-whitespace characters. A match that contains a
336           newline is silently truncated(!) at the newline.
337
338           For example, --word-diff-regex=.  will treat each character as a
339           word and, correspondingly, show differences character by character.
340
341           The regex can also be set via a diff driver or configuration
342           option, see gitattributes(5) or git-config(1). Giving it explicitly
343           overrides any diff driver or configuration setting. Diff drivers
344           override configuration settings.
345
346       --color-words[=<regex>]
347           Equivalent to --word-diff=color plus (if a regex was specified)
348           --word-diff-regex=<regex>.
349
350       --no-renames
351           Turn off rename detection, even when the configuration file gives
352           the default to do so.
353
354       --[no-]rename-empty
355           Whether to use empty blobs as rename source.
356
357       --check
358           Warn if changes introduce conflict markers or whitespace errors.
359           What are considered whitespace errors is controlled by
360           core.whitespace configuration. By default, trailing whitespaces
361           (including lines that consist solely of whitespaces) and a space
362           character that is immediately followed by a tab character inside
363           the initial indent of the line are considered whitespace errors.
364           Exits with non-zero status if problems are found. Not compatible
365           with --exit-code.
366
367       --ws-error-highlight=<kind>
368           Highlight whitespace errors in the context, old or new lines of the
369           diff. Multiple values are separated by comma, none resets previous
370           values, default reset the list to new and all is a shorthand for
371           old,new,context. When this option is not given, and the
372           configuration variable diff.wsErrorHighlight is not set, only
373           whitespace errors in new lines are highlighted. The whitespace
374           errors are colored with color.diff.whitespace.
375
376       --full-index
377           Instead of the first handful of characters, show the full pre- and
378           post-image blob object names on the "index" line when generating
379           patch format output.
380
381       --binary
382           In addition to --full-index, output a binary diff that can be
383           applied with git-apply. Implies --patch.
384
385       --abbrev[=<n>]
386           Instead of showing the full 40-byte hexadecimal object name in
387           diff-raw format output and diff-tree header lines, show only a
388           partial prefix. This is independent of the --full-index option
389           above, which controls the diff-patch output format. Non default
390           number of digits can be specified with --abbrev=<n>.
391
392       -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
393           Break complete rewrite changes into pairs of delete and create.
394           This serves two purposes:
395
396           It affects the way a change that amounts to a total rewrite of a
397           file not as a series of deletion and insertion mixed together with
398           a very few lines that happen to match textually as the context, but
399           as a single deletion of everything old followed by a single
400           insertion of everything new, and the number m controls this aspect
401           of the -B option (defaults to 60%).  -B/70% specifies that less
402           than 30% of the original should remain in the result for Git to
403           consider it a total rewrite (i.e. otherwise the resulting patch
404           will be a series of deletion and insertion mixed together with
405           context lines).
406
407           When used with -M, a totally-rewritten file is also considered as
408           the source of a rename (usually -M only considers a file that
409           disappeared as the source of a rename), and the number n controls
410           this aspect of the -B option (defaults to 50%).  -B20% specifies
411           that a change with addition and deletion compared to 20% or more of
412           the file’s size are eligible for being picked up as a possible
413           source of a rename to another file.
414
415       -M[<n>], --find-renames[=<n>]
416           Detect renames. If n is specified, it is a threshold on the
417           similarity index (i.e. amount of addition/deletions compared to the
418           file’s size). For example, -M90% means Git should consider a
419           delete/add pair to be a rename if more than 90% of the file hasn’t
420           changed. Without a % sign, the number is to be read as a fraction,
421           with a decimal point before it. I.e., -M5 becomes 0.5, and is thus
422           the same as -M50%. Similarly, -M05 is the same as -M5%. To limit
423           detection to exact renames, use -M100%. The default similarity
424           index is 50%.
425
426       -C[<n>], --find-copies[=<n>]
427           Detect copies as well as renames. See also --find-copies-harder. If
428           n is specified, it has the same meaning as for -M<n>.
429
430       --find-copies-harder
431           For performance reasons, by default, -C option finds copies only if
432           the original file of the copy was modified in the same changeset.
433           This flag makes the command inspect unmodified files as candidates
434           for the source of copy. This is a very expensive operation for
435           large projects, so use it with caution. Giving more than one -C
436           option has the same effect.
437
438       -D, --irreversible-delete
439           Omit the preimage for deletes, i.e. print only the header but not
440           the diff between the preimage and /dev/null. The resulting patch is
441           not meant to be applied with patch or git apply; this is solely for
442           people who want to just concentrate on reviewing the text after the
443           change. In addition, the output obviously lacks enough information
444           to apply such a patch in reverse, even manually, hence the name of
445           the option.
446
447           When used together with -B, omit also the preimage in the deletion
448           part of a delete/create pair.
449
450       -l<num>
451           The -M and -C options require O(n^2) processing time where n is the
452           number of potential rename/copy targets. This option prevents
453           rename/copy detection from running if the number of rename/copy
454           targets exceeds the specified number.
455
456       --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
457           Select only files that are Added (A), Copied (C), Deleted (D),
458           Modified (M), Renamed (R), have their type (i.e. regular file,
459           symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
460           (X), or have had their pairing Broken (B). Any combination of the
461           filter characters (including none) can be used. When *
462           (All-or-none) is added to the combination, all paths are selected
463           if there is any file that matches other criteria in the comparison;
464           if there is no file that matches other criteria, nothing is
465           selected.
466
467           Also, these upper-case letters can be downcased to exclude. E.g.
468           --diff-filter=ad excludes added and deleted paths.
469
470           Note that not all diffs can feature all types. For instance, diffs
471           from the index to the working tree can never have Added entries
472           (because the set of paths included in the diff is limited by what
473           is in the index). Similarly, copied and renamed entries cannot
474           appear if detection for those types is disabled.
475
476       -S<string>
477           Look for differences that change the number of occurrences of the
478           specified string (i.e. addition/deletion) in a file. Intended for
479           the scripter’s use.
480
481           It is useful when you’re looking for an exact block of code (like a
482           struct), and want to know the history of that block since it first
483           came into being: use the feature iteratively to feed the
484           interesting block in the preimage back into -S, and keep going
485           until you get the very first version of the block.
486
487           Binary files are searched as well.
488
489       -G<regex>
490           Look for differences whose patch text contains added/removed lines
491           that match <regex>.
492
493           To illustrate the difference between -S<regex> --pickaxe-regex and
494           -G<regex>, consider a commit with the following diff in the same
495           file:
496
497               +    return !regexec(regexp, two->ptr, 1, &regmatch, 0);
498               ...
499               -    hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);
500
501           While git log -G"regexec\(regexp" will show this commit, git log
502           -S"regexec\(regexp" --pickaxe-regex will not (because the number of
503           occurrences of that string did not change).
504
505           Unless --text is supplied patches of binary files without a
506           textconv filter will be ignored.
507
508           See the pickaxe entry in gitdiffcore(7) for more information.
509
510       --find-object=<object-id>
511           Look for differences that change the number of occurrences of the
512           specified object. Similar to -S, just the argument is different in
513           that it doesn’t search for a specific string but for a specific
514           object id.
515
516           The object can be a blob or a submodule commit. It implies the -t
517           option in git-log to also find trees.
518
519       --pickaxe-all
520           When -S or -G finds a change, show all the changes in that
521           changeset, not just the files that contain the change in <string>.
522
523       --pickaxe-regex
524           Treat the <string> given to -S as an extended POSIX regular
525           expression to match.
526
527       -O<orderfile>
528           Control the order in which files appear in the output. This
529           overrides the diff.orderFile configuration variable (see git-
530           config(1)). To cancel diff.orderFile, use -O/dev/null.
531
532           The output order is determined by the order of glob patterns in
533           <orderfile>. All files with pathnames that match the first pattern
534           are output first, all files with pathnames that match the second
535           pattern (but not the first) are output next, and so on. All files
536           with pathnames that do not match any pattern are output last, as if
537           there was an implicit match-all pattern at the end of the file. If
538           multiple pathnames have the same rank (they match the same pattern
539           but no earlier patterns), their output order relative to each other
540           is the normal order.
541
542           <orderfile> is parsed as follows:
543
544           ·   Blank lines are ignored, so they can be used as separators for
545               readability.
546
547           ·   Lines starting with a hash ("#") are ignored, so they can be
548               used for comments. Add a backslash ("\") to the beginning of
549               the pattern if it starts with a hash.
550
551           ·   Each other line contains a single pattern.
552
553           Patterns have the same syntax and semantics as patterns used for
554           fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
555           matches a pattern if removing any number of the final pathname
556           components matches the pattern. For example, the pattern "foo*bar"
557           matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".
558
559       -R
560           Swap two inputs; that is, show differences from index or on-disk
561           file to tree contents.
562
563       --relative[=<path>]
564           When run from a subdirectory of the project, it can be told to
565           exclude changes outside the directory and show pathnames relative
566           to it with this option. When you are not in a subdirectory (e.g. in
567           a bare repository), you can name which subdirectory to make the
568           output relative to by giving a <path> as an argument.
569
570       -a, --text
571           Treat all files as text.
572
573       --ignore-cr-at-eol
574           Ignore carriage-return at the end of line when doing a comparison.
575
576       --ignore-space-at-eol
577           Ignore changes in whitespace at EOL.
578
579       -b, --ignore-space-change
580           Ignore changes in amount of whitespace. This ignores whitespace at
581           line end, and considers all other sequences of one or more
582           whitespace characters to be equivalent.
583
584       -w, --ignore-all-space
585           Ignore whitespace when comparing lines. This ignores differences
586           even if one line has whitespace where the other line has none.
587
588       --ignore-blank-lines
589           Ignore changes whose lines are all blank.
590
591       --inter-hunk-context=<lines>
592           Show the context between diff hunks, up to the specified number of
593           lines, thereby fusing hunks that are close to each other. Defaults
594           to diff.interHunkContext or 0 if the config option is unset.
595
596       -W, --function-context
597           Show whole surrounding functions of changes.
598
599       --exit-code
600           Make the program exit with codes similar to diff(1). That is, it
601           exits with 1 if there were differences and 0 means no differences.
602
603       --quiet
604           Disable all output of the program. Implies --exit-code.
605
606       --ext-diff
607           Allow an external diff helper to be executed. If you set an
608           external diff driver with gitattributes(5), you need to use this
609           option with git-log(1) and friends.
610
611       --no-ext-diff
612           Disallow external diff drivers.
613
614       --textconv, --no-textconv
615           Allow (or disallow) external text conversion filters to be run when
616           comparing binary files. See gitattributes(5) for details. Because
617           textconv filters are typically a one-way conversion, the resulting
618           diff is suitable for human consumption, but cannot be applied. For
619           this reason, textconv filters are enabled by default only for git-
620           diff(1) and git-log(1), but not for git-format-patch(1) or diff
621           plumbing commands.
622
623       --ignore-submodules[=<when>]
624           Ignore changes to submodules in the diff generation. <when> can be
625           either "none", "untracked", "dirty" or "all", which is the default.
626           Using "none" will consider the submodule modified when it either
627           contains untracked or modified files or its HEAD differs from the
628           commit recorded in the superproject and can be used to override any
629           settings of the ignore option in git-config(1) or gitmodules(5).
630           When "untracked" is used submodules are not considered dirty when
631           they only contain untracked content (but they are still scanned for
632           modified content). Using "dirty" ignores all changes to the work
633           tree of submodules, only changes to the commits stored in the
634           superproject are shown (this was the behavior until 1.7.0). Using
635           "all" hides all changes to submodules.
636
637       --src-prefix=<prefix>
638           Show the given source prefix instead of "a/".
639
640       --dst-prefix=<prefix>
641           Show the given destination prefix instead of "b/".
642
643       --no-prefix
644           Do not show any source or destination prefix.
645
646       --line-prefix=<prefix>
647           Prepend an additional prefix to every line of output.
648
649       --ita-invisible-in-index
650           By default entries added by "git add -N" appear as an existing
651           empty file in "git diff" and a new file in "git diff --cached".
652           This option makes the entry appear as a new file in "git diff" and
653           non-existent in "git diff --cached". This option could be reverted
654           with --ita-visible-in-index. Both options are experimental and
655           could be removed in future.
656
657       For more detailed explanation on these common options, see also
658       gitdiffcore(7).
659
660       -1 --base, -2 --ours, -3 --theirs, -0
661           Diff against the "base" version, "our branch" or "their branch"
662           respectively. With these options, diffs for merged entries are not
663           shown.
664
665           The default is to diff against our branch (-2) and the cleanly
666           resolved paths. The option -0 can be given to omit diff output for
667           unmerged entries and just show "Unmerged".
668
669       -c, --cc
670           This compares stage 2 (our branch), stage 3 (their branch) and the
671           working tree file and outputs a combined diff, similar to the way
672           diff-tree shows a merge commit with these flags.
673
674       -q
675           Remain silent even on nonexistent files
676

RAW OUTPUT FORMAT

678       The raw output format from "git-diff-index", "git-diff-tree",
679       "git-diff-files" and "git diff --raw" are very similar.
680
681       These commands all compare two sets of things; what is compared
682       differs:
683
684       git-diff-index <tree-ish>
685           compares the <tree-ish> and the files on the filesystem.
686
687       git-diff-index --cached <tree-ish>
688           compares the <tree-ish> and the index.
689
690       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
691           compares the trees named by the two arguments.
692
693       git-diff-files [<pattern>...]
694           compares the index and the files on the filesystem.
695
696       The "git-diff-tree" command begins its output by printing the hash of
697       what is being compared. After that, all the commands print one output
698       line per changed file.
699
700       An output line is formatted this way:
701
702           in-place edit  :100644 100644 bcd1234 0123456 M file0
703           copy-edit      :100644 100644 abcd123 1234567 C68 file1 file2
704           rename-edit    :100644 100644 abcd123 1234567 R86 file1 file3
705           create         :000000 100644 0000000 1234567 A file4
706           delete         :100644 000000 1234567 0000000 D file5
707           unmerged       :000000 000000 0000000 0000000 U file6
708
709
710       That is, from the left to the right:
711
712        1. a colon.
713
714        2. mode for "src"; 000000 if creation or unmerged.
715
716        3. a space.
717
718        4. mode for "dst"; 000000 if deletion or unmerged.
719
720        5. a space.
721
722        6. sha1 for "src"; 0{40} if creation or unmerged.
723
724        7. a space.
725
726        8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
727
728        9. a space.
729
730       10. status, followed by optional "score" number.
731
732       11. a tab or a NUL when -z option is used.
733
734       12. path for "src"
735
736       13. a tab or a NUL when -z option is used; only exists for C or R.
737
738       14. path for "dst"; only exists for C or R.
739
740       15. an LF or a NUL when -z option is used, to terminate the record.
741
742       Possible status letters are:
743
744       ·   A: addition of a file
745
746       ·   C: copy of a file into a new one
747
748       ·   D: deletion of a file
749
750       ·   M: modification of the contents or mode of a file
751
752       ·   R: renaming of a file
753
754       ·   T: change in the type of the file
755
756       ·   U: file is unmerged (you must complete the merge before it can be
757           committed)
758
759       ·   X: "unknown" change type (most probably a bug, please report it)
760
761       Status letters C and R are always followed by a score (denoting the
762       percentage of similarity between the source and target of the move or
763       copy). Status letter M may be followed by a score (denoting the
764       percentage of dissimilarity) for file rewrites.
765
766       <sha1> is shown as all 0’s if a file is new on the filesystem and it is
767       out of sync with the index.
768
769       Example:
770
771           :100644 100644 5be4a4a 0000000 M file.c
772
773
774       Without the -z option, pathnames with "unusual" characters are quoted
775       as explained for the configuration variable core.quotePath (see git-
776       config(1)). Using -z the filename is output verbatim and the line is
777       terminated by a NUL byte.
778

DIFF FORMAT FOR MERGES

780       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
781       --cc option to generate diff output also for merge commits. The output
782       differs from the format described above in the following way:
783
784        1. there is a colon for each parent
785
786        2. there are more "src" modes and "src" sha1
787
788        3. status is concatenated status characters for each parent
789
790        4. no optional "score" number
791
792        5. tab-separated pathname(s) of the file
793
794       For -c and --cc, only the destination or final path is shown even if
795       the file was renamed on any side of history. With --combined-all-paths,
796       the name of the path in each parent is shown followed by the name of
797       the path in the merge commit.
798
799       Examples for -c and --cc without --combined-all-paths:
800
801           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c
802           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       bar.sh
803           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       phooey.c
804
805
806       Examples when --combined-all-paths added to either -c or --cc:
807
808           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c  desc.c  desc.c
809           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       foo.sh  bar.sh  bar.sh
810           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       fooey.c fuey.c  phooey.c
811
812
813       Note that combined diff lists only files which were modified from all
814       parents.
815

GENERATING PATCH TEXT WITH -P

817       Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
818       diff-tree(1), or git-diff-files(1) with the -p option produces patch
819       text. You can customize the creation of patch text via the
820       GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.
821
822       What the -p option produces is slightly different from the traditional
823       diff format:
824
825        1. It is preceded with a "git diff" header that looks like this:
826
827               diff --git a/file1 b/file2
828
829           The a/ and b/ filenames are the same unless rename/copy is
830           involved. Especially, even for a creation or a deletion, /dev/null
831           is not used in place of the a/ or b/ filenames.
832
833           When rename/copy is involved, file1 and file2 show the name of the
834           source file of the rename/copy and the name of the file that
835           rename/copy produces, respectively.
836
837        2. It is followed by one or more extended header lines:
838
839               old mode <mode>
840               new mode <mode>
841               deleted file mode <mode>
842               new file mode <mode>
843               copy from <path>
844               copy to <path>
845               rename from <path>
846               rename to <path>
847               similarity index <number>
848               dissimilarity index <number>
849               index <hash>..<hash> <mode>
850
851           File modes are printed as 6-digit octal numbers including the file
852           type and file permission bits.
853
854           Path names in extended headers do not include the a/ and b/
855           prefixes.
856
857           The similarity index is the percentage of unchanged lines, and the
858           dissimilarity index is the percentage of changed lines. It is a
859           rounded down integer, followed by a percent sign. The similarity
860           index value of 100% is thus reserved for two equal files, while
861           100% dissimilarity means that no line from the old file made it
862           into the new one.
863
864           The index line includes the blob object names before and after the
865           change. The <mode> is included if the file mode does not change;
866           otherwise, separate lines indicate the old and the new mode.
867
868        3. Pathnames with "unusual" characters are quoted as explained for the
869           configuration variable core.quotePath (see git-config(1)).
870
871        4. All the file1 files in the output refer to files before the commit,
872           and all the file2 files refer to files after the commit. It is
873           incorrect to apply each change to each file sequentially. For
874           example, this patch will swap a and b:
875
876               diff --git a/a b/b
877               rename from a
878               rename to b
879               diff --git a/b b/a
880               rename from b
881               rename to a
882

COMBINED DIFF FORMAT

884       Any diff-generating command can take the -c or --cc option to produce a
885       combined diff when showing a merge. This is the default format when
886       showing merges with git-diff(1) or git-show(1). Note also that you can
887       give the -m option to any of these commands to force generation of
888       diffs with individual parents of a merge.
889
890       A "combined diff" format looks like this:
891
892           diff --combined describe.c
893           index fabadb8,cc95eb0..4866510
894           --- a/describe.c
895           +++ b/describe.c
896           @@@ -98,20 -98,12 +98,20 @@@
897                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
898             }
899
900           - static void describe(char *arg)
901            -static void describe(struct commit *cmit, int last_one)
902           ++static void describe(char *arg, int last_one)
903             {
904            +      unsigned char sha1[20];
905            +      struct commit *cmit;
906                   struct commit_list *list;
907                   static int initialized = 0;
908                   struct commit_name *n;
909
910            +      if (get_sha1(arg, sha1) < 0)
911            +              usage(describe_usage);
912            +      cmit = lookup_commit_reference(sha1);
913            +      if (!cmit)
914            +              usage(describe_usage);
915            +
916                   if (!initialized) {
917                           initialized = 1;
918                           for_each_ref(get_name);
919
920
921
922        1. It is preceded with a "git diff" header, that looks like this (when
923           the -c option is used):
924
925               diff --combined file
926
927           or like this (when the --cc option is used):
928
929               diff --cc file
930
931        2. It is followed by one or more extended header lines (this example
932           shows a merge with two parents):
933
934               index <hash>,<hash>..<hash>
935               mode <mode>,<mode>..<mode>
936               new file mode <mode>
937               deleted file mode <mode>,<mode>
938
939           The mode <mode>,<mode>..<mode> line appears only if at least one of
940           the <mode> is different from the rest. Extended headers with
941           information about detected contents movement (renames and copying
942           detection) are designed to work with diff of two <tree-ish> and are
943           not used by combined diff format.
944
945        3. It is followed by two-line from-file/to-file header
946
947               --- a/file
948               +++ b/file
949
950           Similar to two-line header for traditional unified diff format,
951           /dev/null is used to signal created or deleted files.
952
953           However, if the --combined-all-paths option is provided, instead of
954           a two-line from-file/to-file you get a N+1 line from-file/to-file
955           header, where N is the number of parents in the merge commit
956
957               --- a/file
958               --- a/file
959               --- a/file
960               +++ b/file
961
962           This extended format can be useful if rename or copy detection is
963           active, to allow you to see the original name of the file in
964           different parents.
965
966        4. Chunk header format is modified to prevent people from accidentally
967           feeding it to patch -p1. Combined diff format was created for
968           review of merge commit changes, and was not meant to be applied.
969           The change is similar to the change in the extended index header:
970
971               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
972
973           There are (number of parents + 1) @ characters in the chunk header
974           for combined diff format.
975
976       Unlike the traditional unified diff format, which shows two files A and
977       B with a single column that has - (minus — appears in A but removed in
978       B), + (plus — missing in A but added to B), or " " (space — unchanged)
979       prefix, this format compares two or more files file1, file2,... with
980       one file X, and shows how X differs from each of fileN. One column for
981       each of fileN is prepended to the output line to note how X’s line is
982       different from it.
983
984       A - character in the column N means that the line appears in fileN but
985       it does not appear in the result. A + character in the column N means
986       that the line appears in the result, and fileN does not have that line
987       (in other words, the line was added, from the point of view of that
988       parent).
989
990       In the above example output, the function signature was changed from
991       both files (hence two - removals from both file1 and file2, plus ++ to
992       mean one line that was added does not appear in either file1 or file2).
993       Also eight other lines are the same from file1 but do not appear in
994       file2 (hence prefixed with +).
995
996       When shown by git diff-tree -c, it compares the parents of a merge
997       commit with the merge result (i.e. file1..fileN are the parents). When
998       shown by git diff-files -c, it compares the two unresolved merge
999       parents with the working tree file (i.e. file1 is stage 2 aka "our
1000       version", file2 is stage 3 aka "their version").
1001

OTHER DIFF FORMATS

1003       The --summary option describes newly added, deleted, renamed and copied
1004       files. The --stat option adds diffstat(1) graph to the output. These
1005       options can be combined with other options, such as -p, and are meant
1006       for human consumption.
1007
1008       When showing a change that involves a rename or a copy, --stat output
1009       formats the pathnames compactly by combining common prefix and suffix
1010       of the pathnames. For example, a change that moves arch/i386/Makefile
1011       to arch/x86/Makefile while modifying 4 lines will be shown like this:
1012
1013           arch/{i386 => x86}/Makefile    |   4 +--
1014
1015
1016       The --numstat option gives the diffstat(1) information but is designed
1017       for easier machine consumption. An entry in --numstat output looks like
1018       this:
1019
1020           1       2       README
1021           3       1       arch/{i386 => x86}/Makefile
1022
1023
1024       That is, from left to right:
1025
1026        1. the number of added lines;
1027
1028        2. a tab;
1029
1030        3. the number of deleted lines;
1031
1032        4. a tab;
1033
1034        5. pathname (possibly with rename/copy information);
1035
1036        6. a newline.
1037
1038       When -z output option is in effect, the output is formatted this way:
1039
1040           1       2       README NUL
1041           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
1042
1043
1044       That is:
1045
1046        1. the number of added lines;
1047
1048        2. a tab;
1049
1050        3. the number of deleted lines;
1051
1052        4. a tab;
1053
1054        5. a NUL (only exists if renamed/copied);
1055
1056        6. pathname in preimage;
1057
1058        7. a NUL (only exists if renamed/copied);
1059
1060        8. pathname in postimage (only exists if renamed/copied);
1061
1062        9. a NUL.
1063
1064       The extra NUL before the preimage path in renamed case is to allow
1065       scripts that read the output to tell if the current record being read
1066       is a single-path record or a rename/copy record without reading ahead.
1067       After reading added and deleted lines, reading up to NUL would yield
1068       the pathname, but if that is NUL, the record will show two paths.
1069

GIT

1071       Part of the git(1) suite
1072
1073
1074
1075Git 2.24.1                        12/10/2019                 GIT-DIFF-FILES(1)
Impressum