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

NAME

6       git-diff - Show changes between commits, commit and working tree, etc
7

SYNOPSIS

9       git diff [<options>] [<commit>] [--] [<path>...]
10       git diff [<options>] --cached [<commit>] [--] [<path>...]
11       git diff [<options>] <commit> <commit> [--] [<path>...]
12       git diff [<options>] <blob> <blob>
13       git diff [<options>] --no-index [--] <path> <path>
14
15

DESCRIPTION

17       Show changes between the working tree and the index or a tree, changes
18       between the index and a tree, changes between two trees, changes
19       between two blob objects, or changes between two files on disk.
20
21       git diff [<options>] [--] [<path>...]
22           This form is to view the changes you made relative to the index
23           (staging area for the next commit). In other words, the differences
24           are what you could tell Git to further add to the index but you
25           still haven’t. You can stage these changes by using git-add(1).
26
27       git diff [<options>] --no-index [--] <path> <path>
28           This form is to compare the given two paths on the filesystem. You
29           can omit the --no-index option when running the command in a
30           working tree controlled by Git and at least one of the paths points
31           outside the working tree, or when running the command outside a
32           working tree controlled by Git.
33
34       git diff [<options>] --cached [<commit>] [--] [<path>...]
35           This form is to view the changes you staged for the next commit
36           relative to the named <commit>. Typically you would want comparison
37           with the latest commit, so if you do not give <commit>, it defaults
38           to HEAD. If HEAD does not exist (e.g. unborn branches) and <commit>
39           is not given, it shows all staged changes. --staged is a synonym of
40           --cached.
41
42       git diff [<options>] <commit> [--] [<path>...]
43           This form is to view the changes you have in your working tree
44           relative to the named <commit>. You can use HEAD to compare it with
45           the latest commit, or a branch name to compare with the tip of a
46           different branch.
47
48       git diff [<options>] <commit> <commit> [--] [<path>...]
49           This is to view the changes between two arbitrary <commit>.
50
51       git diff [<options>] <commit>..<commit> [--] [<path>...]
52           This is synonymous to the previous form. If <commit> on one side is
53           omitted, it will have the same effect as using HEAD instead.
54
55       git diff [<options>] <commit>...<commit> [--] [<path>...]
56           This form is to view the changes on the branch containing and up to
57           the second <commit>, starting at a common ancestor of both
58           <commit>. "git diff A...B" is equivalent to "git diff $(git
59           merge-base A B) B". You can omit any one of <commit>, which has the
60           same effect as using HEAD instead.
61
62       Just in case you are doing something exotic, it should be noted that
63       all of the <commit> in the above description, except in the last two
64       forms that use ".." notations, can be any <tree>.
65
66       For a more complete list of ways to spell <commit>, see "SPECIFYING
67       REVISIONS" section in gitrevisions(7). However, "diff" is about
68       comparing two endpoints, not ranges, and the range notations
69       ("<commit>..<commit>" and "<commit>...<commit>") do not mean a range as
70       defined in the "SPECIFYING RANGES" section in gitrevisions(7).
71
72       git diff [<options>] <blob> <blob>
73           This form is to view the differences between the raw contents of
74           two blob objects.
75

OPTIONS

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

RAW OUTPUT FORMAT

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

DIFF FORMAT FOR MERGES

826       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
827       --cc option to generate diff output also for merge commits. The output
828       differs from the format described above in the following way:
829
830        1. there is a colon for each parent
831
832        2. there are more "src" modes and "src" sha1
833
834        3. status is concatenated status characters for each parent
835
836        4. no optional "score" number
837
838        5. single path, only for "dst"
839
840       Example:
841
842           ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM       describe.c
843
844
845       Note that combined diff lists only files which were modified from all
846       parents.
847

GENERATING PATCHES WITH -P

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

COMBINED DIFF FORMAT

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

OTHER DIFF FORMATS

1024       The --summary option describes newly added, deleted, renamed and copied
1025       files. The --stat option adds diffstat(1) graph to the output. These
1026       options can be combined with other options, such as -p, and are meant
1027       for human consumption.
1028
1029       When showing a change that involves a rename or a copy, --stat output
1030       formats the pathnames compactly by combining common prefix and suffix
1031       of the pathnames. For example, a change that moves arch/i386/Makefile
1032       to arch/x86/Makefile while modifying 4 lines will be shown like this:
1033
1034           arch/{i386 => x86}/Makefile    |   4 +--
1035
1036
1037       The --numstat option gives the diffstat(1) information but is designed
1038       for easier machine consumption. An entry in --numstat output looks like
1039       this:
1040
1041           1       2       README
1042           3       1       arch/{i386 => x86}/Makefile
1043
1044
1045       That is, from left to right:
1046
1047        1. the number of added lines;
1048
1049        2. a tab;
1050
1051        3. the number of deleted lines;
1052
1053        4. a tab;
1054
1055        5. pathname (possibly with rename/copy information);
1056
1057        6. a newline.
1058
1059       When -z output option is in effect, the output is formatted this way:
1060
1061           1       2       README NUL
1062           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
1063
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

EXAMPLES

1092       Various ways to check your working tree
1093
1094               $ git diff            (1)
1095               $ git diff --cached   (2)
1096               $ git diff HEAD       (3)
1097
1098           1. Changes in the working tree not yet staged for the next commit.
1099           2. Changes between the index and your last commit; what you would
1100           be committing if you run "git commit" without "-a" option.
1101           3. Changes in the working tree since your last commit; what you
1102           would be committing if you run "git commit -a"
1103
1104       Comparing with arbitrary commits
1105
1106               $ git diff test            (1)
1107               $ git diff HEAD -- ./test  (2)
1108               $ git diff HEAD^ HEAD      (3)
1109
1110           1. Instead of using the tip of the current branch, compare with the
1111           tip of "test" branch.
1112           2. Instead of comparing with the tip of "test" branch, compare with
1113           the tip of the current branch, but limit the comparison to the file
1114           "test".
1115           3. Compare the version before the last commit and the last commit.
1116
1117       Comparing branches
1118
1119               $ git diff topic master    (1)
1120               $ git diff topic..master   (2)
1121               $ git diff topic...master  (3)
1122
1123           1. Changes between the tips of the topic and the master branches.
1124           2. Same as above.
1125           3. Changes that occurred on the master branch since when the topic
1126           branch was started off it.
1127
1128       Limiting the diff output
1129
1130               $ git diff --diff-filter=MRC            (1)
1131               $ git diff --name-status                (2)
1132               $ git diff arch/i386 include/asm-i386   (3)
1133
1134           1. Show only modification, rename, and copy, but not addition or
1135           deletion.
1136           2. Show only names and the nature of change, but not actual diff
1137           output.
1138           3. Limit diff output to named subtrees.
1139
1140       Munging the diff output
1141
1142               $ git diff --find-copies-harder -B -C  (1)
1143               $ git diff -R                          (2)
1144
1145           1. Spend extra cycles to find renames, copies and complete rewrites
1146           (very expensive).
1147           2. Output diff in reverse.
1148

SEE ALSO

1150       diff(1), git-difftool(1), git-log(1), gitdiffcore(7), git-format-
1151       patch(1), git-apply(1)
1152

GIT

1154       Part of the git(1) suite
1155
1156
1157
1158Git 2.21.0                        02/24/2019                       GIT-DIFF(1)
Impressum