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

DESCRIPTION

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

OPTIONS

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

RAW OUTPUT FORMAT

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

DIFF FORMAT FOR MERGES

803       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
804       --cc option to generate diff output also for merge commits. The output
805       differs from the format described above in the following way:
806
807        1. there is a colon for each parent
808
809        2. there are more "src" modes and "src" sha1
810
811        3. status is concatenated status characters for each parent
812
813        4. no optional "score" number
814
815        5. tab-separated pathname(s) of the file
816
817       For -c and --cc, only the destination or final path is shown even if
818       the file was renamed on any side of history. With --combined-all-paths,
819       the name of the path in each parent is shown followed by the name of
820       the path in the merge commit.
821
822       Examples for -c and --cc without --combined-all-paths:
823
824           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c
825           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       bar.sh
826           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       phooey.c
827
828       Examples when --combined-all-paths added to either -c or --cc:
829
830           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       desc.c  desc.c  desc.c
831           ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM       foo.sh  bar.sh  bar.sh
832           ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR       fooey.c fuey.c  phooey.c
833
834       Note that combined diff lists only files which were modified from all
835       parents.
836

GENERATING PATCH TEXT WITH -P

838       Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
839       diff-tree(1), or git-diff-files(1) with the -p option produces patch
840       text. You can customize the creation of patch text via the
841       GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables (see
842       git(1)), and the diff attribute (see gitattributes(5)).
843
844       What the -p option produces is slightly different from the traditional
845       diff format:
846
847        1. It is preceded with a "git diff" header that looks like this:
848
849               diff --git a/file1 b/file2
850
851           The a/ and b/ filenames are the same unless rename/copy is
852           involved. Especially, even for a creation or a deletion, /dev/null
853           is not used in place of the a/ or b/ filenames.
854
855           When rename/copy is involved, file1 and file2 show the name of the
856           source file of the rename/copy and the name of the file that
857           rename/copy produces, respectively.
858
859        2. It is followed by one or more extended header lines:
860
861               old mode <mode>
862               new mode <mode>
863               deleted file mode <mode>
864               new file mode <mode>
865               copy from <path>
866               copy to <path>
867               rename from <path>
868               rename to <path>
869               similarity index <number>
870               dissimilarity index <number>
871               index <hash>..<hash> <mode>
872
873           File modes are printed as 6-digit octal numbers including the file
874           type and file permission bits.
875
876           Path names in extended headers do not include the a/ and b/
877           prefixes.
878
879           The similarity index is the percentage of unchanged lines, and the
880           dissimilarity index is the percentage of changed lines. It is a
881           rounded down integer, followed by a percent sign. The similarity
882           index value of 100% is thus reserved for two equal files, while
883           100% dissimilarity means that no line from the old file made it
884           into the new one.
885
886           The index line includes the blob object names before and after the
887           change. The <mode> is included if the file mode does not change;
888           otherwise, separate lines indicate the old and the new mode.
889
890        3. Pathnames with "unusual" characters are quoted as explained for the
891           configuration variable core.quotePath (see git-config(1)).
892
893        4. All the file1 files in the output refer to files before the commit,
894           and all the file2 files refer to files after the commit. It is
895           incorrect to apply each change to each file sequentially. For
896           example, this patch will swap a and b:
897
898               diff --git a/a b/b
899               rename from a
900               rename to b
901               diff --git a/b b/a
902               rename from b
903               rename to a
904
905        5. Hunk headers mention the name of the function to which the hunk
906           applies. See "Defining a custom hunk-header" in gitattributes(5)
907           for details of how to tailor to this to specific languages.
908

COMBINED DIFF FORMAT

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

OTHER DIFF FORMATS

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

GIT

1092       Part of the git(1) suite
1093
1094
1095
1096Git 2.33.1                        2021-10-12                 GIT-DIFF-FILES(1)
Impressum