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           blocks
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. Adjacent blocks cannot be
235               told apart.
236
237           zebra
238               Blocks of moved text are detected as in blocks mode. The blocks
239               are painted using either the color.diff.{old,new}Moved color or
240               color.diff.{old,new}MovedAlternative. The change between the
241               two colors indicates that a new block was detected.
242
243           dimmed-zebra
244               Similar to zebra, but additional dimming of uninteresting parts
245               of moved code is performed. The bordering lines of two adjacent
246               blocks are considered interesting, the rest is uninteresting.
247               dimmed_zebra is a deprecated synonym.
248
249       --color-moved-ws=<modes>
250           This configures how white spaces are ignored when performing the
251           move detection for --color-moved. These modes can be given as a
252           comma separated list:
253
254           ignore-space-at-eol
255               Ignore changes in whitespace at EOL.
256
257           ignore-space-change
258               Ignore changes in amount of whitespace. This ignores whitespace
259               at line end, and considers all other sequences of one or more
260               whitespace characters to be equivalent.
261
262           ignore-all-space
263               Ignore whitespace when comparing lines. This ignores
264               differences even if one line has whitespace where the other
265               line has none.
266
267           allow-indentation-change
268               Initially ignore any white spaces in the move detection, then
269               group the moved code blocks only into a block if the change in
270               whitespace is the same per line. This is incompatible with the
271               other modes.
272
273       --word-diff[=<mode>]
274           Show a word diff, using the <mode> to delimit changed words. By
275           default, words are delimited by whitespace; see --word-diff-regex
276           below. The <mode> defaults to plain, and must be one of:
277
278           color
279               Highlight changed words using only colors. Implies --color.
280
281           plain
282               Show words as [-removed-] and {+added+}. Makes no attempts to
283               escape the delimiters if they appear in the input, so the
284               output may be ambiguous.
285
286           porcelain
287               Use a special line-based format intended for script
288               consumption. Added/removed/unchanged runs are printed in the
289               usual unified diff format, starting with a +/-/` ` character at
290               the beginning of the line and extending to the end of the line.
291               Newlines in the input are represented by a tilde ~ on a line of
292               its own.
293
294           none
295               Disable word diff again.
296
297           Note that despite the name of the first mode, color is used to
298           highlight the changed parts in all modes if enabled.
299
300       --word-diff-regex=<regex>
301           Use <regex> to decide what a word is, instead of considering runs
302           of non-whitespace to be a word. Also implies --word-diff unless it
303           was already enabled.
304
305           Every non-overlapping match of the <regex> is considered a word.
306           Anything between these matches is considered whitespace and
307           ignored(!) for the purposes of finding differences. You may want to
308           append |[^[:space:]] to your regular expression to make sure that
309           it matches all non-whitespace characters. A match that contains a
310           newline is silently truncated(!) at the newline.
311
312           For example, --word-diff-regex=.  will treat each character as a
313           word and, correspondingly, show differences character by character.
314
315           The regex can also be set via a diff driver or configuration
316           option, see gitattributes(5) or git-config(1). Giving it explicitly
317           overrides any diff driver or configuration setting. Diff drivers
318           override configuration settings.
319
320       --color-words[=<regex>]
321           Equivalent to --word-diff=color plus (if a regex was specified)
322           --word-diff-regex=<regex>.
323
324       --no-renames
325           Turn off rename detection, even when the configuration file gives
326           the default to do so.
327
328       --check
329           Warn if changes introduce conflict markers or whitespace errors.
330           What are considered whitespace errors is controlled by
331           core.whitespace configuration. By default, trailing whitespaces
332           (including lines that consist solely of whitespaces) and a space
333           character that is immediately followed by a tab character inside
334           the initial indent of the line are considered whitespace errors.
335           Exits with non-zero status if problems are found. Not compatible
336           with --exit-code.
337
338       --ws-error-highlight=<kind>
339           Highlight whitespace errors in the context, old or new lines of the
340           diff. Multiple values are separated by comma, none resets previous
341           values, default reset the list to new and all is a shorthand for
342           old,new,context. When this option is not given, and the
343           configuration variable diff.wsErrorHighlight is not set, only
344           whitespace errors in new lines are highlighted. The whitespace
345           errors are colored with color.diff.whitespace.
346
347       --full-index
348           Instead of the first handful of characters, show the full pre- and
349           post-image blob object names on the "index" line when generating
350           patch format output.
351
352       --binary
353           In addition to --full-index, output a binary diff that can be
354           applied with git-apply.
355
356       --abbrev[=<n>]
357           Instead of showing the full 40-byte hexadecimal object name in
358           diff-raw format output and diff-tree header lines, show only a
359           partial prefix. This is independent of the --full-index option
360           above, which controls the diff-patch output format. Non default
361           number of digits can be specified with --abbrev=<n>.
362
363       -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
364           Break complete rewrite changes into pairs of delete and create.
365           This serves two purposes:
366
367           It affects the way a change that amounts to a total rewrite of a
368           file not as a series of deletion and insertion mixed together with
369           a very few lines that happen to match textually as the context, but
370           as a single deletion of everything old followed by a single
371           insertion of everything new, and the number m controls this aspect
372           of the -B option (defaults to 60%).  -B/70% specifies that less
373           than 30% of the original should remain in the result for Git to
374           consider it a total rewrite (i.e. otherwise the resulting patch
375           will be a series of deletion and insertion mixed together with
376           context lines).
377
378           When used with -M, a totally-rewritten file is also considered as
379           the source of a rename (usually -M only considers a file that
380           disappeared as the source of a rename), and the number n controls
381           this aspect of the -B option (defaults to 50%).  -B20% specifies
382           that a change with addition and deletion compared to 20% or more of
383           the file’s size are eligible for being picked up as a possible
384           source of a rename to another file.
385
386       -M[<n>], --find-renames[=<n>]
387           Detect renames. If n is specified, it is a threshold on the
388           similarity index (i.e. amount of addition/deletions compared to the
389           file’s size). For example, -M90% means Git should consider a
390           delete/add pair to be a rename if more than 90% of the file hasn’t
391           changed. Without a % sign, the number is to be read as a fraction,
392           with a decimal point before it. I.e., -M5 becomes 0.5, and is thus
393           the same as -M50%. Similarly, -M05 is the same as -M5%. To limit
394           detection to exact renames, use -M100%. The default similarity
395           index is 50%.
396
397       -C[<n>], --find-copies[=<n>]
398           Detect copies as well as renames. See also --find-copies-harder. If
399           n is specified, it has the same meaning as for -M<n>.
400
401       --find-copies-harder
402           For performance reasons, by default, -C option finds copies only if
403           the original file of the copy was modified in the same changeset.
404           This flag makes the command inspect unmodified files as candidates
405           for the source of copy. This is a very expensive operation for
406           large projects, so use it with caution. Giving more than one -C
407           option has the same effect.
408
409       -D, --irreversible-delete
410           Omit the preimage for deletes, i.e. print only the header but not
411           the diff between the preimage and /dev/null. The resulting patch is
412           not meant to be applied with patch or git apply; this is solely for
413           people who want to just concentrate on reviewing the text after the
414           change. In addition, the output obviously lacks enough information
415           to apply such a patch in reverse, even manually, hence the name of
416           the option.
417
418           When used together with -B, omit also the preimage in the deletion
419           part of a delete/create pair.
420
421       -l<num>
422           The -M and -C options require O(n^2) processing time where n is the
423           number of potential rename/copy targets. This option prevents
424           rename/copy detection from running if the number of rename/copy
425           targets exceeds the specified number.
426
427       --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
428           Select only files that are Added (A), Copied (C), Deleted (D),
429           Modified (M), Renamed (R), have their type (i.e. regular file,
430           symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
431           (X), or have had their pairing Broken (B). Any combination of the
432           filter characters (including none) can be used. When *
433           (All-or-none) is added to the combination, all paths are selected
434           if there is any file that matches other criteria in the comparison;
435           if there is no file that matches other criteria, nothing is
436           selected.
437
438           Also, these upper-case letters can be downcased to exclude. E.g.
439           --diff-filter=ad excludes added and deleted paths.
440
441           Note that not all diffs can feature all types. For instance, diffs
442           from the index to the working tree can never have Added entries
443           (because the set of paths included in the diff is limited by what
444           is in the index). Similarly, copied and renamed entries cannot
445           appear if detection for those types is disabled.
446
447       -S<string>
448           Look for differences that change the number of occurrences of the
449           specified string (i.e. addition/deletion) in a file. Intended for
450           the scripter’s use.
451
452           It is useful when you’re looking for an exact block of code (like a
453           struct), and want to know the history of that block since it first
454           came into being: use the feature iteratively to feed the
455           interesting block in the preimage back into -S, and keep going
456           until you get the very first version of the block.
457
458       -G<regex>
459           Look for differences whose patch text contains added/removed lines
460           that match <regex>.
461
462           To illustrate the difference between -S<regex> --pickaxe-regex and
463           -G<regex>, consider a commit with the following diff in the same
464           file:
465
466               +    return !regexec(regexp, two->ptr, 1, &regmatch, 0);
467               ...
468               -    hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);
469
470           While git log -G"regexec\(regexp" will show this commit, git log
471           -S"regexec\(regexp" --pickaxe-regex will not (because the number of
472           occurrences of that string did not change).
473
474           See the pickaxe entry in gitdiffcore(7) for more information.
475
476       --find-object=<object-id>
477           Look for differences that change the number of occurrences of the
478           specified object. Similar to -S, just the argument is different in
479           that it doesn’t search for a specific string but for a specific
480           object id.
481
482           The object can be a blob or a submodule commit. It implies the -t
483           option in git-log to also find trees.
484
485       --pickaxe-all
486           When -S or -G finds a change, show all the changes in that
487           changeset, not just the files that contain the change in <string>.
488
489       --pickaxe-regex
490           Treat the <string> given to -S as an extended POSIX regular
491           expression to match.
492
493       -O<orderfile>
494           Control the order in which files appear in the output. This
495           overrides the diff.orderFile configuration variable (see git-
496           config(1)). To cancel diff.orderFile, use -O/dev/null.
497
498           The output order is determined by the order of glob patterns in
499           <orderfile>. All files with pathnames that match the first pattern
500           are output first, all files with pathnames that match the second
501           pattern (but not the first) are output next, and so on. All files
502           with pathnames that do not match any pattern are output last, as if
503           there was an implicit match-all pattern at the end of the file. If
504           multiple pathnames have the same rank (they match the same pattern
505           but no earlier patterns), their output order relative to each other
506           is the normal order.
507
508           <orderfile> is parsed as follows:
509
510           ·   Blank lines are ignored, so they can be used as separators for
511               readability.
512
513           ·   Lines starting with a hash ("#") are ignored, so they can be
514               used for comments. Add a backslash ("\") to the beginning of
515               the pattern if it starts with a hash.
516
517           ·   Each other line contains a single pattern.
518
519           Patterns have the same syntax and semantics as patterns used for
520           fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
521           matches a pattern if removing any number of the final pathname
522           components matches the pattern. For example, the pattern "foo*bar"
523           matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".
524
525       -R
526           Swap two inputs; that is, show differences from index or on-disk
527           file to tree contents.
528
529       --relative[=<path>]
530           When run from a subdirectory of the project, it can be told to
531           exclude changes outside the directory and show pathnames relative
532           to it with this option. When you are not in a subdirectory (e.g. in
533           a bare repository), you can name which subdirectory to make the
534           output relative to by giving a <path> as an argument.
535
536       -a, --text
537           Treat all files as text.
538
539       --ignore-cr-at-eol
540           Ignore carriage-return at the end of line when doing a comparison.
541
542       --ignore-space-at-eol
543           Ignore changes in whitespace at EOL.
544
545       -b, --ignore-space-change
546           Ignore changes in amount of whitespace. This ignores whitespace at
547           line end, and considers all other sequences of one or more
548           whitespace characters to be equivalent.
549
550       -w, --ignore-all-space
551           Ignore whitespace when comparing lines. This ignores differences
552           even if one line has whitespace where the other line has none.
553
554       --ignore-blank-lines
555           Ignore changes whose lines are all blank.
556
557       --inter-hunk-context=<lines>
558           Show the context between diff hunks, up to the specified number of
559           lines, thereby fusing hunks that are close to each other. Defaults
560           to diff.interHunkContext or 0 if the config option is unset.
561
562       -W, --function-context
563           Show whole surrounding functions of changes.
564
565       --exit-code
566           Make the program exit with codes similar to diff(1). That is, it
567           exits with 1 if there were differences and 0 means no differences.
568
569       --quiet
570           Disable all output of the program. Implies --exit-code.
571
572       --ext-diff
573           Allow an external diff helper to be executed. If you set an
574           external diff driver with gitattributes(5), you need to use this
575           option with git-log(1) and friends.
576
577       --no-ext-diff
578           Disallow external diff drivers.
579
580       --textconv, --no-textconv
581           Allow (or disallow) external text conversion filters to be run when
582           comparing binary files. See gitattributes(5) for details. Because
583           textconv filters are typically a one-way conversion, the resulting
584           diff is suitable for human consumption, but cannot be applied. For
585           this reason, textconv filters are enabled by default only for git-
586           diff(1) and git-log(1), but not for git-format-patch(1) or diff
587           plumbing commands.
588
589       --ignore-submodules[=<when>]
590           Ignore changes to submodules in the diff generation. <when> can be
591           either "none", "untracked", "dirty" or "all", which is the default.
592           Using "none" will consider the submodule modified when it either
593           contains untracked or modified files or its HEAD differs from the
594           commit recorded in the superproject and can be used to override any
595           settings of the ignore option in git-config(1) or gitmodules(5).
596           When "untracked" is used submodules are not considered dirty when
597           they only contain untracked content (but they are still scanned for
598           modified content). Using "dirty" ignores all changes to the work
599           tree of submodules, only changes to the commits stored in the
600           superproject are shown (this was the behavior until 1.7.0). Using
601           "all" hides all changes to submodules.
602
603       --src-prefix=<prefix>
604           Show the given source prefix instead of "a/".
605
606       --dst-prefix=<prefix>
607           Show the given destination prefix instead of "b/".
608
609       --no-prefix
610           Do not show any source or destination prefix.
611
612       --line-prefix=<prefix>
613           Prepend an additional prefix to every line of output.
614
615       --ita-invisible-in-index
616           By default entries added by "git add -N" appear as an existing
617           empty file in "git diff" and a new file in "git diff --cached".
618           This option makes the entry appear as a new file in "git diff" and
619           non-existent in "git diff --cached". This option could be reverted
620           with --ita-visible-in-index. Both options are experimental and
621           could be removed in future.
622
623       For more detailed explanation on these common options, see also
624       gitdiffcore(7).
625
626       -1 --base, -2 --ours, -3 --theirs, -0
627           Diff against the "base" version, "our branch" or "their branch"
628           respectively. With these options, diffs for merged entries are not
629           shown.
630
631           The default is to diff against our branch (-2) and the cleanly
632           resolved paths. The option -0 can be given to omit diff output for
633           unmerged entries and just show "Unmerged".
634
635       -c, --cc
636           This compares stage 2 (our branch), stage 3 (their branch) and the
637           working tree file and outputs a combined diff, similar to the way
638           diff-tree shows a merge commit with these flags.
639
640       -q
641           Remain silent even on nonexistent files
642

RAW OUTPUT FORMAT

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

DIFF FORMAT FOR MERGES

746       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
747       --cc option to generate diff output also for merge commits. The output
748       differs from the format described above in the following way:
749
750        1. there is a colon for each parent
751
752        2. there are more "src" modes and "src" sha1
753
754        3. status is concatenated status characters for each parent
755
756        4. no optional "score" number
757
758        5. single path, only for "dst"
759
760       Example:
761
762           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       describe.c
763
764
765       Note that combined diff lists only files which were modified from all
766       parents.
767

GENERATING PATCHES WITH -P

769       When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
770       with a -p option, "git diff" without the --raw option, or "git log"
771       with the "-p" option, they do not produce the output described above;
772       instead they produce a patch file. You can customize the creation of
773       such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
774       environment variables.
775
776       What the -p option produces is slightly different from the traditional
777       diff format:
778
779        1. It is preceded with a "git diff" header that looks like this:
780
781               diff --git a/file1 b/file2
782
783           The a/ and b/ filenames are the same unless rename/copy is
784           involved. Especially, even for a creation or a deletion, /dev/null
785           is not used in place of the a/ or b/ filenames.
786
787           When rename/copy is involved, file1 and file2 show the name of the
788           source file of the rename/copy and the name of the file that
789           rename/copy produces, respectively.
790
791        2. It is followed by one or more extended header lines:
792
793               old mode <mode>
794               new mode <mode>
795               deleted file mode <mode>
796               new file mode <mode>
797               copy from <path>
798               copy to <path>
799               rename from <path>
800               rename to <path>
801               similarity index <number>
802               dissimilarity index <number>
803               index <hash>..<hash> <mode>
804
805           File modes are printed as 6-digit octal numbers including the file
806           type and file permission bits.
807
808           Path names in extended headers do not include the a/ and b/
809           prefixes.
810
811           The similarity index is the percentage of unchanged lines, and the
812           dissimilarity index is the percentage of changed lines. It is a
813           rounded down integer, followed by a percent sign. The similarity
814           index value of 100% is thus reserved for two equal files, while
815           100% dissimilarity means that no line from the old file made it
816           into the new one.
817
818           The index line includes the SHA-1 checksum before and after the
819           change. The <mode> is included if the file mode does not change;
820           otherwise, separate lines indicate the old and the new mode.
821
822        3. Pathnames with "unusual" characters are quoted as explained for the
823           configuration variable core.quotePath (see git-config(1)).
824
825        4. All the file1 files in the output refer to files before the commit,
826           and all the file2 files refer to files after the commit. It is
827           incorrect to apply each change to each file sequentially. For
828           example, this patch will swap a and b:
829
830               diff --git a/a b/b
831               rename from a
832               rename to b
833               diff --git a/b b/a
834               rename from b
835               rename to a
836

COMBINED DIFF FORMAT

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

OTHER DIFF FORMATS

944       The --summary option describes newly added, deleted, renamed and copied
945       files. The --stat option adds diffstat(1) graph to the output. These
946       options can be combined with other options, such as -p, and are meant
947       for human consumption.
948
949       When showing a change that involves a rename or a copy, --stat output
950       formats the pathnames compactly by combining common prefix and suffix
951       of the pathnames. For example, a change that moves arch/i386/Makefile
952       to arch/x86/Makefile while modifying 4 lines will be shown like this:
953
954           arch/{i386 => x86}/Makefile    |   4 +--
955
956
957       The --numstat option gives the diffstat(1) information but is designed
958       for easier machine consumption. An entry in --numstat output looks like
959       this:
960
961           1       2       README
962           3       1       arch/{i386 => x86}/Makefile
963
964
965       That is, from left to right:
966
967        1. the number of added lines;
968
969        2. a tab;
970
971        3. the number of deleted lines;
972
973        4. a tab;
974
975        5. pathname (possibly with rename/copy information);
976
977        6. a newline.
978
979       When -z output option is in effect, the output is formatted this way:
980
981           1       2       README NUL
982           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
983
984
985       That is:
986
987        1. the number of added lines;
988
989        2. a tab;
990
991        3. the number of deleted lines;
992
993        4. a tab;
994
995        5. a NUL (only exists if renamed/copied);
996
997        6. pathname in preimage;
998
999        7. a NUL (only exists if renamed/copied);
1000
1001        8. pathname in postimage (only exists if renamed/copied);
1002
1003        9. a NUL.
1004
1005       The extra NUL before the preimage path in renamed case is to allow
1006       scripts that read the output to tell if the current record being read
1007       is a single-path record or a rename/copy record without reading ahead.
1008       After reading added and deleted lines, reading up to NUL would yield
1009       the pathname, but if that is NUL, the record will show two paths.
1010

GIT

1012       Part of the git(1) suite
1013
1014
1015
1016Git 2.20.1                        12/15/2018                 GIT-DIFF-FILES(1)
Impressum