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

RAW OUTPUT FORMAT

614       The raw output format from "git-diff-index", "git-diff-tree",
615       "git-diff-files" and "git diff --raw" are very similar.
616
617       These commands all compare two sets of things; what is compared
618       differs:
619
620       git-diff-index <tree-ish>
621           compares the <tree-ish> and the files on the filesystem.
622
623       git-diff-index --cached <tree-ish>
624           compares the <tree-ish> and the index.
625
626       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
627           compares the trees named by the two arguments.
628
629       git-diff-files [<pattern>...]
630           compares the index and the files on the filesystem.
631
632       The "git-diff-tree" command begins its output by printing the hash of
633       what is being compared. After that, all the commands print one output
634       line per changed file.
635
636       An output line is formatted this way:
637
638           in-place edit  :100644 100644 bcd1234... 0123456... M file0
639           copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
640           rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
641           create         :000000 100644 0000000... 1234567... A file4
642           delete         :100644 000000 1234567... 0000000... D file5
643           unmerged       :000000 000000 0000000... 0000000... U file6
644
645
646       That is, from the left to the right:
647
648        1. a colon.
649
650        2. mode for "src"; 000000 if creation or unmerged.
651
652        3. a space.
653
654        4. mode for "dst"; 000000 if deletion or unmerged.
655
656        5. a space.
657
658        6. sha1 for "src"; 0{40} if creation or unmerged.
659
660        7. a space.
661
662        8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
663
664        9. a space.
665
666       10. status, followed by optional "score" number.
667
668       11. a tab or a NUL when -z option is used.
669
670       12. path for "src"
671
672       13. a tab or a NUL when -z option is used; only exists for C or R.
673
674       14. path for "dst"; only exists for C or R.
675
676       15. an LF or a NUL when -z option is used, to terminate the record.
677
678       Possible status letters are:
679
680       ·   A: addition of a file
681
682       ·   C: copy of a file into a new one
683
684       ·   D: deletion of a file
685
686       ·   M: modification of the contents or mode of a file
687
688       ·   R: renaming of a file
689
690       ·   T: change in the type of the file
691
692       ·   U: file is unmerged (you must complete the merge before it can be
693           committed)
694
695       ·   X: "unknown" change type (most probably a bug, please report it)
696
697       Status letters C and R are always followed by a score (denoting the
698       percentage of similarity between the source and target of the move or
699       copy). Status letter M may be followed by a score (denoting the
700       percentage of dissimilarity) for file rewrites.
701
702       <sha1> is shown as all 0’s if a file is new on the filesystem and it is
703       out of sync with the index.
704
705       Example:
706
707           :100644 100644 5be4a4...... 000000...... M file.c
708
709
710       Without the -z option, pathnames with "unusual" characters are quoted
711       as explained for the configuration variable core.quotePath (see git-
712       config(1)). Using -z the filename is output verbatim and the line is
713       terminated by a NUL byte.
714

DIFF FORMAT FOR MERGES

716       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
717       --cc option to generate diff output also for merge commits. The output
718       differs from the format described above in the following way:
719
720        1. there is a colon for each parent
721
722        2. there are more "src" modes and "src" sha1
723
724        3. status is concatenated status characters for each parent
725
726        4. no optional "score" number
727
728        5. single path, only for "dst"
729
730       Example:
731
732           ::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM      describe.c
733
734
735       Note that combined diff lists only files which were modified from all
736       parents.
737

GENERATING PATCHES WITH -P

739       When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
740       with a -p option, "git diff" without the --raw option, or "git log"
741       with the "-p" option, they do not produce the output described above;
742       instead they produce a patch file. You can customize the creation of
743       such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
744       environment variables.
745
746       What the -p option produces is slightly different from the traditional
747       diff format:
748
749        1. It is preceded with a "git diff" header that looks like this:
750
751               diff --git a/file1 b/file2
752
753           The a/ and b/ filenames are the same unless rename/copy is
754           involved. Especially, even for a creation or a deletion, /dev/null
755           is not used in place of the a/ or b/ filenames.
756
757           When rename/copy is involved, file1 and file2 show the name of the
758           source file of the rename/copy and the name of the file that
759           rename/copy produces, respectively.
760
761        2. It is followed by one or more extended header lines:
762
763               old mode <mode>
764               new mode <mode>
765               deleted file mode <mode>
766               new file mode <mode>
767               copy from <path>
768               copy to <path>
769               rename from <path>
770               rename to <path>
771               similarity index <number>
772               dissimilarity index <number>
773               index <hash>..<hash> <mode>
774
775           File modes are printed as 6-digit octal numbers including the file
776           type and file permission bits.
777
778           Path names in extended headers do not include the a/ and b/
779           prefixes.
780
781           The similarity index is the percentage of unchanged lines, and the
782           dissimilarity index is the percentage of changed lines. It is a
783           rounded down integer, followed by a percent sign. The similarity
784           index value of 100% is thus reserved for two equal files, while
785           100% dissimilarity means that no line from the old file made it
786           into the new one.
787
788           The index line includes the SHA-1 checksum before and after the
789           change. The <mode> is included if the file mode does not change;
790           otherwise, separate lines indicate the old and the new mode.
791
792        3. Pathnames with "unusual" characters are quoted as explained for the
793           configuration variable core.quotePath (see git-config(1)).
794
795        4. All the file1 files in the output refer to files before the commit,
796           and all the file2 files refer to files after the commit. It is
797           incorrect to apply each change to each file sequentially. For
798           example, this patch will swap a and b:
799
800               diff --git a/a b/b
801               rename from a
802               rename to b
803               diff --git a/b b/a
804               rename from b
805               rename to a
806

COMBINED DIFF FORMAT

808       Any diff-generating command can take the -c or --cc option to produce a
809       combined diff when showing a merge. This is the default format when
810       showing merges with git-diff(1) or git-show(1). Note also that you can
811       give the -m option to any of these commands to force generation of
812       diffs with individual parents of a merge.
813
814       A combined diff format looks like this:
815
816           diff --combined describe.c
817           index fabadb8,cc95eb0..4866510
818           --- a/describe.c
819           +++ b/describe.c
820           @@@ -98,20 -98,12 +98,20 @@@
821                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
822             }
823
824           - static void describe(char *arg)
825            -static void describe(struct commit *cmit, int last_one)
826           ++static void describe(char *arg, int last_one)
827             {
828            +      unsigned char sha1[20];
829            +      struct commit *cmit;
830                   struct commit_list *list;
831                   static int initialized = 0;
832                   struct commit_name *n;
833
834            +      if (get_sha1(arg, sha1) < 0)
835            +              usage(describe_usage);
836            +      cmit = lookup_commit_reference(sha1);
837            +      if (!cmit)
838            +              usage(describe_usage);
839            +
840                   if (!initialized) {
841                           initialized = 1;
842                           for_each_ref(get_name);
843
844
845
846        1. It is preceded with a "git diff" header, that looks like this (when
847           -c option is used):
848
849               diff --combined file
850
851           or like this (when --cc option is used):
852
853               diff --cc file
854
855        2. It is followed by one or more extended header lines (this example
856           shows a merge with two parents):
857
858               index <hash>,<hash>..<hash>
859               mode <mode>,<mode>..<mode>
860               new file mode <mode>
861               deleted file mode <mode>,<mode>
862
863           The mode <mode>,<mode>..<mode> line appears only if at least one of
864           the <mode> is different from the rest. Extended headers with
865           information about detected contents movement (renames and copying
866           detection) are designed to work with diff of two <tree-ish> and are
867           not used by combined diff format.
868
869        3. It is followed by two-line from-file/to-file header
870
871               --- a/file
872               +++ b/file
873
874           Similar to two-line header for traditional unified diff format,
875           /dev/null is used to signal created or deleted files.
876
877        4. Chunk header format is modified to prevent people from accidentally
878           feeding it to patch -p1. Combined diff format was created for
879           review of merge commit changes, and was not meant for apply. The
880           change is similar to the change in the extended index header:
881
882               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
883
884           There are (number of parents + 1) @ characters in the chunk header
885           for combined diff format.
886
887       Unlike the traditional unified diff format, which shows two files A and
888       B with a single column that has - (minus — appears in A but removed in
889       B), + (plus — missing in A but added to B), or " " (space — unchanged)
890       prefix, this format compares two or more files file1, file2,... with
891       one file X, and shows how X differs from each of fileN. One column for
892       each of fileN is prepended to the output line to note how X’s line is
893       different from it.
894
895       A - character in the column N means that the line appears in fileN but
896       it does not appear in the result. A + character in the column N means
897       that the line appears in the result, and fileN does not have that line
898       (in other words, the line was added, from the point of view of that
899       parent).
900
901       In the above example output, the function signature was changed from
902       both files (hence two - removals from both file1 and file2, plus ++ to
903       mean one line that was added does not appear in either file1 or file2).
904       Also eight other lines are the same from file1 but do not appear in
905       file2 (hence prefixed with +).
906
907       When shown by git diff-tree -c, it compares the parents of a merge
908       commit with the merge result (i.e. file1..fileN are the parents). When
909       shown by git diff-files -c, it compares the two unresolved merge
910       parents with the working tree file (i.e. file1 is stage 2 aka "our
911       version", file2 is stage 3 aka "their version").
912

OTHER DIFF FORMATS

914       The --summary option describes newly added, deleted, renamed and copied
915       files. The --stat option adds diffstat(1) graph to the output. These
916       options can be combined with other options, such as -p, and are meant
917       for human consumption.
918
919       When showing a change that involves a rename or a copy, --stat output
920       formats the pathnames compactly by combining common prefix and suffix
921       of the pathnames. For example, a change that moves arch/i386/Makefile
922       to arch/x86/Makefile while modifying 4 lines will be shown like this:
923
924           arch/{i386 => x86}/Makefile    |   4 +--
925
926
927       The --numstat option gives the diffstat(1) information but is designed
928       for easier machine consumption. An entry in --numstat output looks like
929       this:
930
931           1       2       README
932           3       1       arch/{i386 => x86}/Makefile
933
934
935       That is, from left to right:
936
937        1. the number of added lines;
938
939        2. a tab;
940
941        3. the number of deleted lines;
942
943        4. a tab;
944
945        5. pathname (possibly with rename/copy information);
946
947        6. a newline.
948
949       When -z output option is in effect, the output is formatted this way:
950
951           1       2       README NUL
952           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
953
954
955       That is:
956
957        1. the number of added lines;
958
959        2. a tab;
960
961        3. the number of deleted lines;
962
963        4. a tab;
964
965        5. a NUL (only exists if renamed/copied);
966
967        6. pathname in preimage;
968
969        7. a NUL (only exists if renamed/copied);
970
971        8. pathname in postimage (only exists if renamed/copied);
972
973        9. a NUL.
974
975       The extra NUL before the preimage path in renamed case is to allow
976       scripts that read the output to tell if the current record being read
977       is a single-path record or a rename/copy record without reading ahead.
978       After reading added and deleted lines, reading up to NUL would yield
979       the pathname, but if that is NUL, the record will show two paths.
980

GIT

982       Part of the git(1) suite
983
984
985
986Git 2.18.1                        05/14/2019                 GIT-DIFF-FILES(1)
Impressum