3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
7 .\" Source: Git 2.48.0.rc2.27.g14650065b7
10 .TH "GIT\-DIFF" "1" "2025-01-07" "Git 2\&.48\&.0\&.rc2\&.27\&.g1" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-diff \- Show changes between commits, commit and working tree, etc
35 \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fI<commit>\fR] [\fB\-\-\fR] [\fI<path>\fR\&...\:]
36 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-cached\fR [\fB\-\-merge\-base\fR] [\fI<commit>\fR] [\fB\-\-\fR] [\fI<path>\fR\&...\:]
37 \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-merge\-base\fR] \fI<commit>\fR [\fI<commit>\fR\&...\:] \fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&...\:]
38 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR`\&...\:\fB__\fR\fI<commit>\fR\fB__\fR [{empty}\-\-{empty}]{empty} [\fB__\fR\fI<path>\fR\fB__\&.\&.\fR\&.]{empty}
39 {empty}`git \fBdiff\fR [\fI<options>\fR] \fI<blob>\fR \fI<blob>\fR
40 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-no\-index\fR [\fB\-\-\fR] \fI<path>\fR \fI<path>\fR
44 Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes resulting from a merge, changes between two blob objects, or changes between two files on disk\&.
46 \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
48 This form is to view the changes you made relative to the index (staging area for the next commit)\&. In other words, the differences are what you
50 tell Git to further add to the index but you still haven\(cqt\&. You can stage these changes by using
54 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-no\-index\fR [\fB\-\-\fR] \fI<path>\fR \fI<path>\fR
56 This form is to compare the given two paths on the filesystem\&. You can omit the
58 option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git\&. This form implies
59 \fB\-\-exit\-code\fR\&.
62 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fB\-\-cached\fR [\fB\-\-merge\-base\fR] [\fI<commit>\fR] [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
64 This form is to view the changes you staged for the next commit relative to the named
65 \fI<commit>\fR\&. Typically you would want comparison with the latest commit, so if you do not give
66 \fI<commit>\fR, it defaults to
69 does not exist (e\&.g\&. unborn branches) and
71 is not given, it shows all staged changes\&.
78 is given, instead of using
79 \fI<commit>\fR, use the merge base of
98 \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-merge\-base\fR] \fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
100 This form is to view the changes you have in your working tree relative to the named
101 \fI<commit>\fR\&. You can use
103 to compare it with the latest commit, or a branch name to compare with the tip of a different branch\&.
106 \fB\-\-merge\-base\fR
107 is given, instead of using
108 \fI<commit>\fR, use the merge base of
114 \fB\-\-merge\-base\fR
125 \fBgit\fR \fBdiff\fR [\fI<options>\fR] [\fB\-\-merge\-base\fR] \fI<commit>\fR \fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
127 This is to view the changes between two arbitrary
131 \fB\-\-merge\-base\fR
132 is given, use the merge base of the two commits for the "before" side\&.
135 \fB\-\-merge\-base\fR
148 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR \fI<commit>\fR\fB\&.\&.\&.\fR\fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
150 This form is to view the results of a merge commit\&. The first listed
152 must be the merge itself; the remaining two or more commits should be its parents\&. Convenient ways to produce the desired set of revisions are to use the suffixes
157 is a merge commit, then
168 all give the same combined diff\&.
171 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR\fB\&.\&.\fR\fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
173 This is synonymous to the earlier form (without the \&.\&.) for viewing the changes between two arbitrary
176 on one side is omitted, it will have the same effect as using
181 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<commit>\fR\fB\&.\&.\&.\fR\fI<commit>\fR [\fB\-\-\fR] [\fI<path>\fR\&.\&.\&.]
183 This form is to view the changes on the branch containing and up to the second
184 \fI<commit>\fR, starting at a common ancestor of both
188 \fBA\fR\fB\&.\&.\&.\fR\fBB\fR
196 \fBB\fR\&. You can omit any one of
197 \fI<commit>\fR, which has the same effect as using
202 Just in case you are doing something exotic, it should be noted that all of the \fI<commit>\fR in the above description, except in the \fB\-\-merge\-base\fR case and in the last two forms that use \&.\&. notations, can be any \fI<tree>\fR\&. A tree of interest is the one pointed to by the ref named \fBAUTO_MERGE\fR, which is written by the \fBort\fR merge strategy upon hitting merge conflicts (see \fBgit-merge\fR(1))\&. Comparing the working tree with \fBAUTO_MERGE\fR shows changes you\(cqve made so far to resolve textual conflicts (see the examples below)\&.
204 For a more complete list of ways to spell \fI<commit>\fR, see "SPECIFYING REVISIONS" section in \fBgitrevisions\fR(7)\&. However, \fBdiff\fR is about comparing two \fIendpoints\fR, not ranges, and the range notations (\fI<commit>\fR\fB\&.\&.\fR\fI<commit>\fR and \fI<commit>\fR\fB\&.\&.\&.\fR\fI<commit>\fR) do not mean a range as defined in the "SPECIFYING RANGES" section in \fBgitrevisions\fR(7)\&.
206 \fBgit\fR \fBdiff\fR [\fI<options>\fR] \fI<blob>\fR \fI<blob>\fR
208 This form is to view the differences between the raw contents of two blob objects\&.
212 \fB\-p\fR, \fB\-u\fR, \fB\-\-patch\fR
215 the section called \(lqGENERATING PATCH TEXT WITH \-P\(rq)\&. This is the default\&.
218 \fB\-s\fR, \fB\-\-no\-patch\fR
220 Suppress all output from the diff machinery\&. Useful for commands like
223 that show the patch by default to squelch their output, or to cancel the effect of options like
226 earlier on the command line in an alias\&.
229 \fB\-U\fR\fI<n>\fR, \fB\-\-unified=\fR\fI<n>\fR
233 lines of context instead of the usual three\&. Implies
237 \fB\-\-output=\fR\fI<file>\fR
239 Output to a specific file instead of stdout\&.
242 \fB\-\-output\-indicator\-new=\fR\fI<char>\fR, \fB\-\-output\-indicator\-old=\fR\fI<char>\fR, \fB\-\-output\-indicator\-context=\fR\fI<char>\fR
244 Specify the character used to indicate new, old or context lines in the generated patch\&. Normally they are
247 and \*(Aq \*(Aq respectively\&.
252 Generate the diff in raw format\&.
255 \fB\-\-patch\-with\-raw\fR
262 \fB\-\-indent\-heuristic\fR
264 Enable the heuristic that shifts diff hunk boundaries to make patches easier to read\&. This is the default\&.
267 \fB\-\-no\-indent\-heuristic\fR
269 Disable the indent heuristic\&.
274 Spend extra time to make sure the smallest possible diff is produced\&.
279 Generate a diff using the "patience diff" algorithm\&.
284 Generate a diff using the "histogram diff" algorithm\&.
287 \fB\-\-anchored=\fR\fI<text>\fR
289 Generate a diff using the "anchored diff" algorithm\&.
291 This option may be specified more than once\&.
293 If a line exists in both the source and destination, exists only once, and starts with
294 \fI<text>\fR, this algorithm attempts to prevent it from appearing as a deletion or addition in the output\&. It uses the "patience diff" algorithm internally\&.
297 \fB\-\-diff\-algorithm=\fR(\fBpatience\fR|\fBminimal\fR|\fBhistogram\fR|\fBmyers\fR)
299 Choose a diff algorithm\&. The variants are as follows:
301 \fBdefault\fR, \fBmyers\fR
303 The basic greedy diff algorithm\&. Currently, this is the default\&.
308 Spend extra time to make sure the smallest possible diff is produced\&.
313 Use "patience diff" algorithm when generating patches\&.
318 This algorithm extends the patience algorithm to "support low\-occurrence common elements"\&.
321 For instance, if you configured the
322 \fBdiff\&.algorithm\fR
323 variable to a non\-default value and want to use the default one, then you have to use
324 \fB\-\-diff\-algorithm=default\fR
328 \fB\-\-stat\fR[\fB=\fR\fI<width>\fR[\fB,\fR\fI<name\-width>\fR[\fB,\fR\fI<count>\fR]]]
330 Generate a diffstat\&. By default, as much space as necessary will be used for the filename part, and the rest for the graph part\&. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by
331 \fI<width>\fR\&. The width of the filename part can be limited by giving another width
333 after a comma or by setting
334 \fBdiff\&.statNameWidth=\fR\fI<name\-width>\fR\&. The width of the graph part can be limited by using
335 \fB\-\-stat\-graph\-width=\fR\fI<graph\-width>\fR
337 \fBdiff\&.statGraphWidth=\fR\fI<graph\-width>\fR\&. Using
340 \fB\-\-stat\-graph\-width\fR
341 affects all commands generating a stat graph, while setting
342 \fBdiff\&.statNameWidth\fR
344 \fBdiff\&.statGraphWidth\fR
347 \fBformat\-patch\fR\&. By giving a third parameter
348 \fI<count>\fR, you can limit the output to the first
350 lines, followed by \&.\&.\&. if there are more\&.
352 These parameters can also be set individually with
353 \fB\-\-stat\-width=\fR\fI<width>\fR,
354 \fB\-\-stat\-name\-width=\fR\fI<name\-width>\fR
356 \fB\-\-stat\-count=\fR\fI<count>\fR\&.
359 \fB\-\-compact\-summary\fR
361 Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally
363 if it\(cqs a symlink) and mode changes (\fB+x\fR
366 for adding or removing executable bit respectively) in diffstat\&. The information is put between the filename part and the graph part\&. Implies
373 \fB\-\-stat\fR, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly\&. For binary files, outputs two
382 Output only the last line of the
384 format containing total number of modified files, as well as number of added and deleted lines\&.
387 \fB\-X\fR [\fI<param>\fR\fB,\&.\&.\fR\&.], \fB\-\-dirstat\fR[\fB=\fR\fI<param>\fR\fB,\&.\&.\fR\&.]
389 Output the distribution of relative amount of changes for each sub\-directory\&. The behavior of
391 can be customized by passing it a comma separated list of parameters\&. The defaults are controlled by the
393 configuration variable (see
394 \fBgit-config\fR(1))\&. The following parameters are available:
398 Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination\&. This ignores the amount of pure code movements within a file\&. In other words, rearranging lines in a file is not counted as much as other changes\&. This is the default behavior when no parameter is given\&.
403 Compute the dirstat numbers by doing the regular line\-based diff analysis, and summing the removed/added line counts\&. (For binary files, count 64\-byte chunks instead, since binary files have no natural concept of lines)\&. This is a more expensive
407 behavior, but it does count rearranged lines within a file as much as other changes\&. The resulting output is consistent with what you get from the other
408 \fB\-\-\fR*stat options\&.
413 Compute the dirstat numbers by counting the number of files changed\&. Each changed file counts equally in the dirstat analysis\&. This is the computationally cheapest
415 behavior, since it does not have to look at the file contents at all\&.
420 Count changes in a child directory for the parent directory as well\&. Note that when using
421 \fBcumulative\fR, the sum of the percentages reported may exceed 100%\&. The default (non\-cumulative) behavior can be specified with the
428 An integer parameter specifies a cut\-off percent (3% by default)\&. Directories contributing less than this percentage of the changes are not shown in the output\&.
431 Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories:
432 \fB\-\-dirstat=files,10,cumulative\fR\&.
438 \fB\-\-dirstat=cumulative\fR\&.
441 \fB\-\-dirstat\-by\-file\fR[\fB=\fR\fI<param>\fR\fB,\&.\&.\fR\&.]
444 \fB\-\-dirstat=files,\fR\fI<param>\fR\fB,\&.\&.\fR\&.\&.
449 Output a condensed summary of extended header information such as creations, renames and mode changes\&.
452 \fB\-\-patch\-with\-stat\fR
466 \fB\-\-name\-status\fR
467 has been given, do not munge pathnames and use NULs as output field terminators\&.
469 Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable
470 \fBcore\&.quotePath\fR
472 \fBgit-config\fR(1))\&.
477 Show only the name of each changed file in the post\-image tree\&. The file names are often encoded in UTF\-8\&. For more information see the discussion about encoding in the
482 \fB\-\-name\-status\fR
484 Show only the name(s) and status of each changed file\&. See the description of the
485 \fB\-\-diff\-filter\fR
486 option on what the status letters mean\&. Just like
488 the file names are often encoded in UTF\-8\&.
491 \fB\-\-submodule\fR[\fB=\fR\fI<format>\fR]
493 Specify how differences in submodules are shown\&. When specifying
494 \fB\-\-submodule=short\fR
497 format is used\&. This format just shows the names of the commits at the beginning and end of the range\&. When
500 \fB\-\-submodule=log\fR
503 format is used\&. This format lists the commits in the range like
504 \fBgit-submodule\fR(1)
507 \fB\-\-submodule=diff\fR
510 format is used\&. This format shows an inline diff of the changes in the submodule contents between the commit range\&. Defaults to
511 \fBdiff\&.submodule\fR
514 format if the config option is unset\&.
517 \fB\-\-color\fR[\fB=\fR\fI<when>\fR]
522 \fB=\fR\fI<when>\fR) is the same as
523 \fB\-\-color=always\fR\&.
528 \fBauto\fR\&. It can be changed by the
532 configuration settings\&.
537 Turn off colored diff\&. This can be used to override configuration settings\&. It is the same as
538 \fB\-\-color=never\fR\&.
541 \fB\-\-color\-moved\fR[\fB=\fR\fI<mode>\fR]
543 Moved lines of code are colored differently\&. It can be changed by the
544 \fBdiff\&.colorMoved\fR
545 configuration setting\&. The
549 if the option is not given and to
551 if the option with no mode is given\&. The mode must be one of:
555 Moved lines are not highlighted\&.
561 \fBzebra\fR\&. This may change to a more sensible mode in the future\&.
566 Any line that is added in one location and was removed in another location will be colored with
567 \fBcolor\&.diff\&.newMoved\fR\&. Similarly
568 \fBcolor\&.diff\&.oldMoved\fR
569 will be used for removed lines that are added somewhere else in the diff\&. This mode picks up any moved line, but it is not very useful in a review to determine if a block of code was moved without permutation\&.
574 Blocks of moved text of at least 20 alphanumeric characters are detected greedily\&. The detected blocks are painted using either the
575 \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMoved\fR
576 color\&. Adjacent blocks cannot be told apart\&.
581 Blocks of moved text are detected as in
583 mode\&. The blocks are painted using either the
584 \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMoved\fR
586 \fBcolor\&.diff\&.\fR(\fBold\fR|\fBnew\fR)\fBMovedAlternative\fR\&. The change between the two colors indicates that a new block was detected\&.
592 \fBzebra\fR, but additional dimming of uninteresting parts of moved code is performed\&. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting\&.
594 is a deprecated synonym\&.
598 \fB\-\-no\-color\-moved\fR
600 Turn off move detection\&. This can be used to override configuration settings\&. It is the same as
601 \fB\-\-color\-moved=no\fR\&.
604 \fB\-\-color\-moved\-ws=\fR\fI<mode>\fR\fB,\&.\&.\fR\&.
606 This configures how whitespace is ignored when performing the move detection for
607 \fB\-\-color\-moved\fR\&. It can be set by the
608 \fBdiff\&.colorMovedWS\fR
609 configuration setting\&. These modes can be given as a comma separated list:
613 Do not ignore whitespace when performing move detection\&.
616 \fBignore\-space\-at\-eol\fR
618 Ignore changes in whitespace at EOL\&.
621 \fBignore\-space\-change\fR
623 Ignore changes in amount of whitespace\&. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent\&.
626 \fBignore\-all\-space\fR
628 Ignore whitespace when comparing lines\&. This ignores differences even if one line has whitespace where the other line has none\&.
631 \fBallow\-indentation\-change\fR
633 Initially ignore any whitespace in the move detection, then group the moved code blocks only into a block if the change in whitespace is the same per line\&. This is incompatible with the other modes\&.
637 \fB\-\-no\-color\-moved\-ws\fR
639 Do not ignore whitespace when performing move detection\&. This can be used to override configuration settings\&. It is the same as
640 \fB\-\-color\-moved\-ws=no\fR\&.
643 \fB\-\-word\-diff\fR[\fB=\fR\fI<mode>\fR]
645 By default, words are delimited by whitespace; see
646 \fB\-\-word\-diff\-regex\fR
650 \fBplain\fR, and must be one of:
654 Highlight changed words using only colors\&. Implies
660 Show words as [\fB\-removed\-\fR] and {\fBadded\fR}\&. Makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous\&.
665 Use a special line\-based format intended for script consumption\&. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a
666 \fB+\fR/\fB\-\fR/` ` character at the beginning of the line and extending to the end of the line\&. Newlines in the input are represented by a tilde
668 on a line of its own\&.
673 Disable word diff again\&.
676 Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled\&.
679 \fB\-\-word\-diff\-regex=\fR\fI<regex>\fR
683 to decide what a word is, instead of considering runs of non\-whitespace to be a word\&. Also implies
685 unless it was already enabled\&.
687 Every non\-overlapping match of the
689 is considered a word\&. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences\&. You may want to append |[\fB^\fR[\fB:space:\fR]] to your regular expression to make sure that it matches all non\-whitespace characters\&. A match that contains a newline is silently truncated(!) at the newline\&.
692 \fB\-\-word\-diff\-regex=\&.\fR
693 will treat each character as a word and, correspondingly, show differences character by character\&.
695 The regex can also be set via a diff driver or configuration option, see
696 \fBgitattributes\fR(5)
698 \fBgit-config\fR(1)\&. Giving it explicitly overrides any diff driver or configuration setting\&. Diff drivers override configuration settings\&.
701 \fB\-\-color\-words\fR[\fB=\fR\fI<regex>\fR]
704 \fB\-\-word\-diff=color\fR
705 plus (if a regex was specified)
706 \fB\-\-word\-diff\-regex=\fR\fI<regex>\fR\&.
709 \fB\-\-no\-renames\fR
711 Turn off rename detection, even when the configuration file gives the default to do so\&.
714 \fB\-\-\fR[\fBno\-\fR]\fBrename\-empty\fR
716 Whether to use empty blobs as rename source\&.
721 Warn if changes introduce conflict markers or whitespace errors\&. What are considered whitespace errors is controlled by
722 \fBcore\&.whitespace\fR
723 configuration\&. By default, trailing whitespaces (including lines that consist solely of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors\&. Exits with non\-zero status if problems are found\&. Not compatible with
724 \fB\-\-exit\-code\fR\&.
727 \fB\-\-ws\-error\-highlight=\fR\fI<kind>\fR
729 Highlight whitespace errors in the
734 lines of the diff\&. Multiple values are separated by comma,
736 resets previous values,
743 \fBold,new,context\fR\&. When this option is not given, and the configuration variable
744 \fBdiff\&.wsErrorHighlight\fR
745 is not set, only whitespace errors in
747 lines are highlighted\&. The whitespace errors are colored with
748 \fBcolor\&.diff\&.whitespace\fR\&.
751 \fB\-\-full\-index\fR
753 Instead of the first handful of characters, show the full pre\- and post\-image blob object names on the "index" line when generating patch format output\&.
759 \fB\-\-full\-index\fR, output a binary diff that can be applied with
760 \fBgit\-apply\fR\&. Implies
764 \fB\-\-abbrev\fR[\fB=\fR\fI<n>\fR]
766 Instead of showing the full 40\-byte hexadecimal object name in diff\-raw format output and diff\-tree header lines, show the shortest prefix that is at least
768 hexdigits long that uniquely refers the object\&. In diff\-patch output format,
769 \fB\-\-full\-index\fR
770 takes higher precedence, i\&.e\&. if
771 \fB\-\-full\-index\fR
772 is specified, full blob names will be shown regardless of
773 \fB\-\-abbrev\fR\&. Non default number of digits can be specified with
774 \fB\-\-abbrev=\fR\fI<n>\fR\&.
777 \fB\-B\fR[\fI<n>\fR][\fB/\fR\fI<m>\fR], \fB\-\-break\-rewrites\fR[\fB=\fR[\fI<n>\fR][\fB/\fR\fI<m>\fR]]
779 Break complete rewrite changes into pairs of delete and create\&. This serves two purposes:
781 It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new, and the number
783 controls this aspect of the
785 option (defaults to 60%)\&.
786 \fB\-B/70\fR% specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i\&.e\&. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines)\&.
789 \fB\-M\fR, a totally\-rewritten file is also considered as the source of a rename (usually
791 only considers a file that disappeared as the source of a rename), and the number
793 controls this aspect of the
795 option (defaults to 50%)\&.
796 \fB\-B20\fR% specifies that a change with addition and deletion compared to 20% or more of the file\(cqs size are eligible for being picked up as a possible source of a rename to another file\&.
799 \fB\-M\fR[\fI<n>\fR], \fB\-\-find\-renames\fR[\fB=\fR\fI<n>\fR]
803 is specified, it is a threshold on the similarity index (i\&.e\&. amount of addition/deletions compared to the file\(cqs size)\&. For example,
804 \fB\-M90\fR% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn\(cqt changed\&. Without a % sign, the number is to be read as a fraction, with a decimal point before it\&. I\&.e\&.,
806 becomes 0\&.5, and is thus the same as
807 \fB\-M50\fR%\&. Similarly,
810 \fB\-M5\fR%\&. To limit detection to exact renames, use
811 \fB\-M100\fR%\&. The default similarity index is 50%\&.
814 \fB\-C\fR[\fI<n>\fR], \fB\-\-find\-copies\fR[\fB=\fR\fI<n>\fR]
816 Detect copies as well as renames\&. See also
817 \fB\-\-find\-copies\-harder\fR\&. If
819 is specified, it has the same meaning as for
820 \fB\-M\fR\fI<n>\fR\&.
823 \fB\-\-find\-copies\-harder\fR
825 For performance reasons, by default,
827 option finds copies only if the original file of the copy was modified in the same changeset\&. This flag makes the command inspect unmodified files as candidates for the source of copy\&. This is a very expensive operation for large projects, so use it with caution\&. Giving more than one
829 option has the same effect\&.
832 \fB\-D\fR, \fB\-\-irreversible\-delete\fR
834 Omit the preimage for deletes, i\&.e\&. print only the header but not the diff between the preimage and
835 \fB/dev/null\fR\&. The resulting patch is not meant to be applied with
839 \fBapply\fR; this is solely for people who want to just concentrate on reviewing the text after the change\&. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option\&.
841 When used together with
842 \fB\-B\fR, omit also the preimage in the deletion part of a delete/create pair\&.
851 options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources\&. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant\&.) For N sources and destinations, this exhaustive check is O(N^2)\&. This option prevents the exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number\&. Defaults to
852 \fBdiff\&.renameLimit\fR\&. Note that a value of 0 is treated as unlimited\&.
855 \fB\-\-diff\-filter=\fR[(\fBA\fR|\fBC\fR|\fBD\fR|\fBM\fR|\fBR\fR|\fBT\fR|\fBU\fR|\fBX\fR|\fBB\fR)\fB\&.\&.\&.\fR[*]]
857 Select only files that are Added (\fBA\fR), Copied (\fBC\fR), Deleted (\fBD\fR), Modified (\fBM\fR), Renamed (\fBR\fR), have their type (i\&.e\&. regular file, symlink, submodule, \&...\:) changed (\fBT\fR), are Unmerged (\fBU\fR), are Unknown (\fBX\fR), or have had their pairing Broken (\fBB\fR)\&. Any combination of the filter characters (including none) can be used\&. When * (All\-or\-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected\&.
859 Also, these upper\-case letters can be downcased to exclude\&. E\&.g\&.
860 \fB\-\-diff\-filter=ad\fR
861 excludes added and deleted paths\&.
863 Note that not all diffs can feature all types\&. For instance, copied and renamed entries cannot appear if detection for those types is disabled\&.
866 \fB\-S\fR\fI<string>\fR
868 Look for differences that change the number of occurrences of the specified
870 (i\&.e\&. addition/deletion) in a file\&. Intended for the scripter\(cqs use\&.
872 It is useful when you\(cqre looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into
873 \fB\-S\fR, and keep going until you get the very first version of the block\&.
875 Binary files are searched as well\&.
878 \fB\-G\fR\fI<regex>\fR
880 Look for differences whose patch text contains added/removed lines that match
883 To illustrate the difference between
884 \fB\-S\fR\fI<regex>\fR
885 \fB\-\-pickaxe\-regex\fR
887 \fB\-G\fR\fI<regex>\fR, consider a commit with the following diff in the same file:
893 + return frotz(nitfol, two\->ptr, 1, 0);
895 \- hit = frotz(nitfol, mf2\&.ptr, 1, 0);
904 \fB\-G\fR"frotz\e(\fBnitfol\fR" will show this commit,
907 \fB\-S\fR"frotz\e(\fBnitfol\fR"
908 \fB\-\-pickaxe\-regex\fR
909 will not (because the number of occurrences of that string did not change)\&.
913 is supplied patches of binary files without a textconv filter will be ignored\&.
919 for more information\&.
922 \fB\-\-find\-object=\fR\fI<object\-id>\fR
924 Look for differences that change the number of occurrences of the specified object\&. Similar to
925 \fB\-S\fR, just the argument is different in that it doesn\(cqt search for a specific string but for a specific object id\&.
927 The object can be a blob or a submodule commit\&. It implies the
931 to also find trees\&.
934 \fB\-\-pickaxe\-all\fR
940 finds a change, show all the changes in that changeset, not just the files that contain the change in
944 \fB\-\-pickaxe\-regex\fR
950 as an extended POSIX regular expression to match\&.
953 \fB\-O\fR\fI<orderfile>\fR
955 Control the order in which files appear in the output\&. This overrides the
956 \fBdiff\&.orderFile\fR
957 configuration variable (see
958 \fBgit-config\fR(1))\&. To cancel
959 \fBdiff\&.orderFile\fR, use
960 \fB\-O/dev/null\fR\&.
962 The output order is determined by the order of glob patterns in
963 \fI<orderfile>\fR\&. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on\&. All files with pathnames that do not match any pattern are output last, as if there was an implicit match\-all pattern at the end of the file\&. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order\&.
966 is parsed as follows:
976 Blank lines are ignored, so they can be used as separators for readability\&.
987 Lines starting with a hash ("#") are ignored, so they can be used for comments\&. Add a backslash ("\e") to the beginning of the pattern if it starts with a hash\&.
998 Each other line contains a single pattern\&.
1001 Patterns have the same syntax and semantics as patterns used for
1002 \fBfnmatch\fR(3) without the
1004 flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern\&. For example, the pattern "\fBfoo\fR*bar" matches "\fBfooasdfbar\fR" and "\fBfoo/bar/baz/asdf\fR" but not "\fBfoobarx\fR"\&.
1007 \fB\-\-skip\-to=\fR\fI<file>\fR, \fB\-\-rotate\-to=\fR\fI<file>\fR
1009 Discard the files before the named
1011 from the output (i\&.e\&.
1012 \fIskip to\fR), or move them to the end of the output (i\&.e\&.
1013 \fIrotate to\fR)\&. These options were invented primarily for the use of the
1016 command, and may not be very useful otherwise\&.
1021 Swap two inputs; that is, show differences from index or on\-disk file to tree contents\&.
1024 \fB\-\-relative\fR[\fB=\fR\fI<path>\fR], \fB\-\-no\-relative\fR
1026 When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option\&. When you are not in a subdirectory (e\&.g\&. in a bare repository), you can name which subdirectory to make the output relative to by giving a
1029 \fB\-\-no\-relative\fR
1030 can be used to countermand both
1031 \fBdiff\&.relative\fR
1032 config option and previous
1033 \fB\-\-relative\fR\&.
1036 \fB\-a\fR, \fB\-\-text\fR
1038 Treat all files as text\&.
1041 \fB\-\-ignore\-cr\-at\-eol\fR
1043 Ignore carriage\-return at the end of line when doing a comparison\&.
1046 \fB\-\-ignore\-space\-at\-eol\fR
1048 Ignore changes in whitespace at EOL\&.
1051 \fB\-b\fR, \fB\-\-ignore\-space\-change\fR
1053 Ignore changes in amount of whitespace\&. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent\&.
1056 \fB\-w\fR, \fB\-\-ignore\-all\-space\fR
1058 Ignore whitespace when comparing lines\&. This ignores differences even if one line has whitespace where the other line has none\&.
1061 \fB\-\-ignore\-blank\-lines\fR
1063 Ignore changes whose lines are all blank\&.
1066 \fB\-I\fR\fI<regex>\fR, \fB\-\-ignore\-matching\-lines=\fR\fI<regex>\fR
1068 Ignore changes whose all lines match
1069 \fI<regex>\fR\&. This option may be specified more than once\&.
1072 \fB\-\-inter\-hunk\-context=\fR\fI<number>\fR
1074 Show the context between diff hunks, up to the specified
1076 of lines, thereby fusing hunks that are close to each other\&. Defaults to
1077 \fBdiff\&.interHunkContext\fR
1078 or 0 if the config option is unset\&.
1081 \fB\-W\fR, \fB\-\-function\-context\fR
1083 Show whole function as context lines for each change\&. The function names are determined in the same way as
1086 works out patch hunk headers (see "Defining a custom hunk\-header" in
1087 \fBgitattributes\fR(5))\&.
1090 \fB\-\-exit\-code\fR
1092 Make the program exit with codes similar to
1093 \fBdiff\fR(1)\&. That is, it exits with 1 if there were differences and 0 means no differences\&.
1098 Disable all output of the program\&. Implies
1099 \fB\-\-exit\-code\fR\&. Disables execution of external diff helpers whose exit code is not trusted, i\&.e\&. their respective configuration option
1100 \fBdiff\&.trustExitCode\fR
1102 \fBdiff\&.\fR\fI<driver>\fR\&.\fBtrustExitCode\fR
1103 or environment variable
1104 \fBGIT_EXTERNAL_DIFF_TRUST_EXIT_CODE\fR
1110 Allow an external diff helper to be executed\&. If you set an external diff driver with
1111 \fBgitattributes\fR(5), you need to use this option with
1116 \fB\-\-no\-ext\-diff\fR
1118 Disallow external diff drivers\&.
1121 \fB\-\-textconv\fR, \fB\-\-no\-textconv\fR
1123 Allow (or disallow) external text conversion filters to be run when comparing binary files\&. See
1124 \fBgitattributes\fR(5)
1125 for details\&. Because textconv filters are typically a one\-way conversion, the resulting diff is suitable for human consumption, but cannot be applied\&. For this reason, textconv filters are enabled by default only for
1128 \fBgit-log\fR(1), but not for
1129 \fBgit-format-patch\fR(1)
1130 or diff plumbing commands\&.
1133 \fB\-\-ignore\-submodules\fR[\fB=\fR(\fBnone\fR|\fBuntracked\fR|\fBdirty\fR|\fBall\fR)]
1135 Ignore changes to submodules in the diff generation\&.
1137 is the default\&. Using
1139 will consider the submodule modified when it either contains untracked or modified files or its
1141 differs from the commit recorded in the superproject and can be used to override any settings of the
1146 \fBgitmodules\fR(5)\&. When
1148 is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content)\&. Using
1150 ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior until 1\&.7\&.0)\&. Using
1152 hides all changes to submodules\&.
1155 \fB\-\-src\-prefix=\fR\fI<prefix>\fR
1157 Show the given source
1162 \fB\-\-dst\-prefix=\fR\fI<prefix>\fR
1164 Show the given destination
1169 \fB\-\-no\-prefix\fR
1171 Do not show any source or destination prefix\&.
1174 \fB\-\-default\-prefix\fR
1176 Use the default source and destination prefixes ("a/" and "b/")\&. This overrides configuration variables such as
1177 \fBdiff\&.noprefix\fR,
1178 \fBdiff\&.srcPrefix\fR,
1179 \fBdiff\&.dstPrefix\fR, and
1180 \fBdiff\&.mnemonicPrefix\fR
1182 \fBgit-config\fR(1))\&.
1185 \fB\-\-line\-prefix=\fR\fI<prefix>\fR
1187 Prepend an additional
1189 to every line of output\&.
1192 \fB\-\-ita\-invisible\-in\-index\fR
1194 By default entries added by
1198 appear as an existing empty file in
1204 \fB\-\-cached\fR\&. This option makes the entry appear as a new file in
1207 and non\-existent in
1210 \fB\-\-cached\fR\&. This option could be reverted with
1211 \fB\-\-ita\-visible\-in\-index\fR\&. Both options are experimental and could be removed in future\&.
1214 For more detailed explanation on these common options, see also \fBgitdiffcore\fR(7)\&.
1216 \fB\-1\fR, \fB\-\-base\fR, \fB\-2\fR, \fB\-\-ours\fR, \fB\-3\fR, \fB\-\-theirs\fR
1218 Compare the working tree with
1222 \h'-04'\(bu\h'+03'\c
1228 the "base" version (stage #1) when using
1236 \h'-04'\(bu\h'+03'\c
1242 "our branch" (stage #2) when using
1250 \h'-04'\(bu\h'+03'\c
1256 "their branch" (stage #3) when using
1262 The index contains these stages only for unmerged entries i\&.e\&. while resolving conflicts\&. See
1263 \fBgit-read-tree\fR(1)
1264 section "3\-Way Merge" for detailed information\&.
1269 Omit diff output for unmerged entries and just show "Unmerged"\&. Can be used only when comparing the working tree with the index\&.
1272 \fI<path>\fR\&.\&.\&.
1276 parameters, when given, are used to limit the diff to the named paths (you can give directory names and get diff for all files under them)\&.
1278 .SH "RAW OUTPUT FORMAT"
1280 The raw output format from \fBgit\-diff\-index\fR, \fBgit\-diff\-tree\fR, \fBgit\-diff\-files\fR and \fBgit\fR \fBdiff\fR \fB\-\-raw\fR are very similar\&.
1282 These commands all compare two sets of things; what is compared differs:
1284 \fBgit\-diff\-index\fR \fI<tree\-ish>\fR
1288 and the files on the filesystem\&.
1291 \fBgit\-diff\-index\fR \fB\-\-cached\fR \fI<tree\-ish>\fR
1298 \fBgit\-diff\-tree\fR [\fB\-r\fR] \fI<tree\-ish\-1>\fR \fI<tree\-ish\-2>\fR [\fI<pattern>\fR\&.\&.\&.]
1300 compares the trees named by the two arguments\&.
1303 \fBgit\-diff\-files\fR [\fI<pattern>\fR\&.\&.\&.]
1305 compares the index and the files on the filesystem\&.
1308 The \fBgit\-diff\-tree\fR command begins its output by printing the hash of what is being compared\&. After that, all the commands print one output line per changed file\&.
1310 An output line is formatted this way:
1316 in\-place edit :100644 100644 bcd1234 0123456 M file0
1317 copy\-edit :100644 100644 abcd123 1234567 C68 file1 file2
1318 rename\-edit :100644 100644 abcd123 1234567 R86 file1 file3
1319 create :000000 100644 0000000 1234567 A file4
1320 delete :100644 000000 1234567 0000000 D file5
1321 unmerged :000000 000000 0000000 0000000 U file6
1327 That is, from the left to the right:
1348 mode for "src"; 000000 if creation or unmerged\&.
1370 mode for "dst"; 000000 if deletion or unmerged\&.
1392 sha1 for "src"; 0{40} if creation or unmerged\&.
1414 sha1 for "dst"; 0{40} if deletion, unmerged or "work tree out of sync with the index"\&.
1436 status, followed by optional "score" number\&.
1473 option is used; only exists for C or R\&.
1484 path for "dst"; only exists for C or R\&.
1497 option is used, to terminate the record\&.
1500 Possible status letters are:
1504 \h'-04'\(bu\h'+03'\c
1510 \fBA\fR: addition of a file
1515 \h'-04'\(bu\h'+03'\c
1521 \fBC\fR: copy of a file into a new one
1526 \h'-04'\(bu\h'+03'\c
1532 \fBD\fR: deletion of a file
1537 \h'-04'\(bu\h'+03'\c
1543 \fBM\fR: modification of the contents or mode of a file
1548 \h'-04'\(bu\h'+03'\c
1554 \fBR\fR: renaming of a file
1559 \h'-04'\(bu\h'+03'\c
1565 \fBT\fR: change in the type of the file (regular file, symbolic link or submodule)
1570 \h'-04'\(bu\h'+03'\c
1576 \fBU\fR: file is unmerged (you must complete the merge before it can be committed)
1581 \h'-04'\(bu\h'+03'\c
1587 \fBX\fR: "unknown" change type (most probably a bug, please report it)
1590 Status letters \fBC\fR and \fBR\fR are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy)\&. Status letter \fBM\fR may be followed by a score (denoting the percentage of dissimilarity) for file rewrites\&.
1592 The sha1 for "dst" is shown as all 0\(cqs if a file on the filesystem is out of sync with the index\&.
1600 :100644 100644 5be4a4a 0000000 M file\&.c
1606 Without the \fB\-z\fR option, pathnames with "unusual" characters are quoted as explained for the configuration variable \fBcore\&.quotePath\fR (see \fBgit-config\fR(1))\&. Using \fB\-z\fR the filename is output verbatim and the line is terminated by a NUL byte\&.
1607 .SH "DIFF FORMAT FOR MERGES"
1609 \fBgit\-diff\-tree\fR, \fBgit\-diff\-files\fR and \fBgit\-diff\fR \fB\-\-raw\fR can take \fB\-c\fR or \fB\-\-cc\fR option to generate diff output also for merge commits\&. The output differs from the format described above in the following way:
1619 there is a colon for each parent
1630 there are more "src" modes and "src" sha1
1641 status is concatenated status characters for each parent
1652 no optional "score" number
1663 tab\-separated pathname(s) of the file
1666 For \fB\-c\fR and \fB\-\-cc\fR, only the destination or final path is shown even if the file was renamed on any side of history\&. With \fB\-\-combined\-all\-paths\fR, the name of the path in each parent is shown followed by the name of the path in the merge commit\&.
1668 Examples for \fB\-c\fR and \fB\-\-cc\fR without \fB\-\-combined\-all\-paths\fR:
1674 ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc\&.c
1675 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar\&.sh
1676 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey\&.c
1682 Examples when \fB\-\-combined\-all\-paths\fR added to either \fB\-c\fR or \fB\-\-cc\fR:
1688 ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc\&.c desc\&.c desc\&.c
1689 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo\&.sh bar\&.sh bar\&.sh
1690 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey\&.c fuey\&.c phooey\&.c
1696 Note that \fIcombined diff\fR lists only files which were modified from all parents\&.
1697 .SH "GENERATING PATCH TEXT WITH \-P"
1699 Running \fBgit-diff\fR(1), \fBgit-log\fR(1), \fBgit-show\fR(1), \fBgit-diff-index\fR(1), \fBgit-diff-tree\fR(1), or \fBgit-diff-files\fR(1) with the \fB\-p\fR option produces patch text\&. You can customize the creation of patch text via the \fBGIT_EXTERNAL_DIFF\fR and the \fBGIT_DIFF_OPTS\fR environment variables (see \fBgit\fR(1)), and the \fBdiff\fR attribute (see \fBgitattributes\fR(5))\&.
1701 What the \fB\-p\fR option produces is slightly different from the traditional diff format:
1711 It is preceded by a "git diff" header that looks like this:
1717 diff \-\-git a/file1 b/file2
1727 filenames are the same unless rename/copy is involved\&. Especially, even for a creation or a deletion,
1731 used in place of the
1737 When a rename/copy is involved,
1741 show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively\&.
1752 It is followed by one or more extended header lines:
1758 \fBold\fR \fBmode\fR \fI<mode>\fR
1759 \fBnew\fR \fBmode\fR \fI<mode>\fR
1760 \fBdeleted\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
1761 \fBnew\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
1762 \fBcopy\fR \fBfrom\fR \fI<path>\fR
1763 \fBcopy\fR \fBto\fR \fI<path>\fR
1764 \fBrename\fR \fBfrom\fR \fI<path>\fR
1765 \fBrename\fR \fBto\fR \fI<path>\fR
1766 \fBsimilarity\fR \fBindex\fR \fI<number>\fR
1767 \fBdissimilarity\fR \fBindex\fR \fI<number>\fR
1768 \fBindex\fR \fI<hash>\fR`\&.\&.`\fI<hash>\fR \fI<mode>\fR
1775 are printed as 6\-digit octal numbers including the file type and file permission bits\&.
1777 Path names in extended headers do not include the
1783 The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines\&. It is a rounded down integer, followed by a percent sign\&. The similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one\&.
1785 The index line includes the blob object names before and after the change\&. The
1787 is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode\&.
1798 Pathnames with "unusual" characters are quoted as explained for the configuration variable
1799 \fBcore\&.quotePath\fR
1801 \fBgit-config\fR(1))\&.
1814 files in the output refer to files before the commit, and all the
1816 files refer to files after the commit\&. It is incorrect to apply each change to each file sequentially\&. For example, this patch will swap a and b:
1822 diff \-\-git a/a b/b
1825 diff \-\-git a/b b/a
1842 Hunk headers mention the name of the function to which the hunk applies\&. See "Defining a custom hunk\-header" in
1843 \fBgitattributes\fR(5)
1844 for details of how to tailor this to specific languages\&.
1846 .SH "COMBINED DIFF FORMAT"
1848 Any diff\-generating command can take the \fB\-c\fR or \fB\-\-cc\fR option to produce a \fIcombined diff\fR when showing a merge\&. This is the default format when showing merges with \fBgit-diff\fR(1) or \fBgit-show\fR(1)\&. Note also that you can give suitable \fB\-\-diff\-merges\fR option to any of these commands to force generation of diffs in a specific format\&.
1850 A "combined diff" format looks like this:
1856 diff \-\-combined describe\&.c
1857 index fabadb8,cc95eb0\&.\&.4866510
1858 \-\-\- a/describe\&.c
1860 @@@ \-98,20 \-98,12 +98,20 @@@
1861 return (a_date > b_date) ? \-1 : (a_date == b_date) ? 0 : 1;
1864 \- static void describe(char *arg)
1865 \-static void describe(struct commit *cmit, int last_one)
1866 ++static void describe(char *arg, int last_one)
1868 + unsigned char sha1[20];
1869 + struct commit *cmit;
1870 struct commit_list *list;
1871 static int initialized = 0;
1872 struct commit_name *n;
1874 + if (get_sha1(arg, sha1) < 0)
1875 + usage(describe_usage);
1876 + cmit = lookup_commit_reference(sha1);
1878 + usage(describe_usage);
1882 for_each_ref(get_name);
1896 It is preceded by a "git diff" header, that looks like this (when the
1904 diff \-\-combined file
1910 or like this (when the
1933 It is followed by one or more extended header lines (this example shows a merge with two parents):
1939 \fBindex\fR \fI<hash>\fR\fB,\fR\fI<hash>\fR`\&.\&.\fB__\fR\fI<hash>\fR\fB__\fR
1940 {empty}`mode \fI<mode>\fR\fB,\fR\fI<mode>\fR``\&.\&.``\fI<mode>\fR
1941 \fBnew\fR \fBfile\fR \fBmode\fR \fI<mode>\fR
1942 \fBdeleted\fR \fBfile\fR \fBmode\fR \fI<mode>\fR\fB,\fR\fI<mode>\fR
1949 \fI<mode>\fR\fB,\fR\fI<mode>\fR\fB\&.\&.\fR\fI<mode>\fR
1950 line appears only if at least one of the <mode> is different from the rest\&. Extended headers with information about detected content movement (renames and copying detection) are designed to work with the diff of two
1952 and are not used by combined diff format\&.
1963 It is followed by a two\-line from\-file/to\-file header:
1976 Similar to the two\-line header for the traditional
1980 is used to signal created or deleted files\&.
1982 However, if the \-\-combined\-all\-paths option is provided, instead of a two\-line from\-file/to\-file, you get an N+1 line from\-file/to\-file header, where N is the number of parents in the merge commit:
1997 This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents\&.
2008 Chunk header format is modified to prevent people from accidentally feeding it to
2010 \fB\-p1\fR\&. Combined diff format was created for review of merge commit changes, and was not meant to be applied\&. The change is similar to the change in the extended
2018 @@@ <from\-file\-range> <from\-file\-range> <to\-file\-range> @@@
2024 There are (number of parents + 1)
2026 characters in the chunk header for combined diff format\&.
2029 Unlike the traditional \fIunified\fR diff format, which shows two files A and B with a single column that has \fB\-\fR (minus \(em appears in A but removed in B), \fB+\fR (plus \(em missing in A but added to B), or " " (space \(em unchanged) prefix, this format compares two or more files file1, file2,\&...\: with one file X, and shows how X differs from each of fileN\&. One column for each of fileN is prepended to the output line to note how X\(cqs line is different from it\&.
2031 A \fB\-\fR character in the column N means that the line appears in fileN but it does not appear in the result\&. A \fB+\fR character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent)\&.
2033 In the above example output, the function signature was changed from both files (hence two \fB\-\fR removals from both file1 and file2, plus \fB++\fR to mean one line that was added does not appear in either file1 or file2)\&. Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with \fB+\fR)\&.
2035 When shown by \fBgit\fR \fBdiff\-tree\fR \fB\-c\fR, it compares the parents of a merge commit with the merge result (i\&.e\&. file1\&.\&.fileN are the parents)\&. When shown by \fBgit\fR \fBdiff\-files\fR \fB\-c\fR, it compares the two unresolved merge parents with the working tree file (i\&.e\&. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version")\&.
2036 .SH "OTHER DIFF FORMATS"
2038 The \fB\-\-summary\fR option describes newly added, deleted, renamed and copied files\&. The \fB\-\-stat\fR option adds \fBdiffstat\fR(1) graph to the output\&. These options can be combined with other options, such as \fB\-p\fR, and are meant for human consumption\&.
2040 When showing a change that involves a rename or a copy, \fB\-\-stat\fR output formats the pathnames compactly by combining common prefix and suffix of the pathnames\&. For example, a change that moves \fBarch/i386/Makefile\fR to \fBarch/x86/Makefile\fR while modifying 4 lines will be shown like this:
2046 arch/{i386 => x86}/Makefile | 4 +\-\-
2052 The \fB\-\-numstat\fR option gives the diffstat(1) information but is designed for easier machine consumption\&. An entry in \fB\-\-numstat\fR output looks like this:
2059 3 1 arch/{i386 => x86}/Makefile
2065 That is, from left to right:
2075 the number of added lines;
2097 the number of deleted lines;
2119 pathname (possibly with rename/copy information);
2133 When \fB\-z\fR output option is in effect, the output is formatted this way:
2140 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
2156 the number of added lines;
2178 the number of deleted lines;
2200 a NUL (only exists if renamed/copied);
2211 pathname in preimage;
2222 a NUL (only exists if renamed/copied);
2233 pathname in postimage (only exists if renamed/copied);
2247 The extra \fBNUL\fR before the preimage path in renamed case is to allow scripts that read the output to tell if the current record being read is a single\-path record or a rename/copy record without reading ahead\&. After reading added and deleted lines, reading up to \fBNUL\fR would yield the pathname, but if that is \fBNUL\fR, the record will show two paths\&.
2250 Various ways to check your working tree
2257 $ git diff \fB(1)\fR
2258 $ git diff \-\-cached \fB(2)\fR
2259 $ git diff HEAD \fB(3)\fR
2260 $ git diff AUTO_MERGE \fB(4)\fR
2267 r lw(\n(.lu*75u/100u).
2269 Changes in the working tree not yet staged for the next commit\&.
2272 Changes between the index and your last commit; what you would be committing if you run
2280 Changes in the working tree since your last commit; what you would be committing if you run
2286 Changes in the working tree you\(cqve made to resolve textual conflicts so far\&.
2291 Comparing with arbitrary commits
2298 $ git diff test \fB(1)\fR
2299 $ git diff HEAD \-\- \&./test \fB(2)\fR
2300 $ git diff HEAD^ HEAD \fB(3)\fR
2307 r lw(\n(.lu*75u/100u).
2309 Instead of using the tip of the current branch, compare with the tip of "test" branch\&.
2312 Instead of comparing with the tip of "test" branch, compare with the tip of the current branch, but limit the comparison to the file "test"\&.
2315 Compare the version before the last commit and the last commit\&.
2327 $ git diff topic master \fB(1)\fR
2328 $ git diff topic\&.\&.master \fB(2)\fR
2329 $ git diff topic\&.\&.\&.master \fB(3)\fR
2336 r lw(\n(.lu*75u/100u).
2338 Changes between the tips of the topic and the master branches\&.
2344 Changes that occurred on the master branch since when the topic branch was started off it\&.
2349 Limiting the diff output
2356 $ git diff \-\-diff\-filter=MRC \fB(1)\fR
2357 $ git diff \-\-name\-status \fB(2)\fR
2358 $ git diff arch/i386 include/asm\-i386 \fB(3)\fR
2365 r lw(\n(.lu*75u/100u).
2367 Show only modification, rename, and copy, but not addition or deletion\&.
2370 Show only names and the nature of change, but not actual diff output\&.
2373 Limit diff output to named subtrees\&.
2378 Munging the diff output
2385 $ git diff \-\-find\-copies\-harder \-B \-C \fB(1)\fR
2386 $ git diff \-R \fB(2)\fR
2393 r lw(\n(.lu*75u/100u).
2395 Spend extra cycles to find renames, copies and complete rewrites (very expensive)\&.
2398 Output diff in reverse\&.
2404 Everything below this line in this section is selectively included from the \fBgit-config\fR(1) documentation\&. The content is the same as what\(cqs found there:
2406 \fBdiff\&.autoRefreshIndex\fR
2411 to compare with work tree files, do not consider stat\-only changes as changed\&. Instead, silently run
2415 to update the cached stat information for paths whose contents in the work tree match the contents in the index\&. This option defaults to
2416 \fBtrue\fR\&. Note that this affects only
2419 Porcelain, and not lower level
2423 \fBdiff\-files\fR\&.
2426 \fBdiff\&.dirstat\fR
2428 A comma separated list of
2430 parameters specifying the default behavior of the
2435 and friends\&. The defaults can be overridden on the command line (using
2436 \fB\-\-dirstat=\fR\fI<param>\fR\fB,\&.\&.\fR\&.)\&. The fallback defaults (when not changed by
2437 \fBdiff\&.dirstat\fR) are
2438 \fBchanges,noncumulative,3\fR\&. The following parameters are available:
2442 Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination\&. This ignores the amount of pure code movements within a file\&. In other words, rearranging lines in a file is not counted as much as other changes\&. This is the default behavior when no parameter is given\&.
2447 Compute the dirstat numbers by doing the regular line\-based diff analysis, and summing the removed/added line counts\&. (For binary files, count 64\-byte chunks instead, since binary files have no natural concept of lines)\&. This is a more expensive
2451 behavior, but it does count rearranged lines within a file as much as other changes\&. The resulting output is consistent with what you get from the other
2452 \fB\-\-\fR*stat options\&.
2457 Compute the dirstat numbers by counting the number of files changed\&. Each changed file counts equally in the dirstat analysis\&. This is the computationally cheapest
2459 behavior, since it does not have to look at the file contents at all\&.
2464 Count changes in a child directory for the parent directory as well\&. Note that when using
2465 \fBcumulative\fR, the sum of the percentages reported may exceed 100%\&. The default (non\-cumulative) behavior can be specified with the
2472 An integer parameter specifies a cut\-off percent (3% by default)\&. Directories contributing less than this percentage of the changes are not shown in the output\&.
2475 Example: The following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories:
2476 \fBfiles,10,cumulative\fR\&.
2479 \fBdiff\&.statNameWidth\fR
2481 Limit the width of the filename part in
2483 output\&. If set, applies to all commands generating
2486 \fBformat\-patch\fR\&.
2489 \fBdiff\&.statGraphWidth\fR
2491 Limit the width of the graph part in
2493 output\&. If set, applies to all commands generating
2496 \fBformat\-patch\fR\&.
2499 \fBdiff\&.context\fR
2503 lines of context instead of the default of 3\&. This value is overridden by the
2508 \fBdiff\&.interHunkContext\fR
2510 Show the context between diff hunks, up to the specified number of lines, thereby fusing the hunks that are close to each other\&. This value serves as the default for the
2511 \fB\-\-inter\-hunk\-context\fR
2512 command line option\&.
2515 \fBdiff\&.external\fR
2517 If this config variable is set, diff generation is not performed using the internal diff machinery, but using the given command\&. Can be overridden with the
2518 \fBGIT_EXTERNAL_DIFF\fR
2519 environment variable\&. The command is called with parameters as described under "git Diffs" in
2520 \fBgit\fR(1)\&. Note: if you want to use an external diff program only on a subset of your files, you might want to use
2521 \fBgitattributes\fR(5)
2525 \fBdiff\&.trustExitCode\fR
2527 If this boolean value is set to
2530 \fBdiff\&.external\fR
2531 command is expected to return exit code 0 if it considers the input files to be equal or 1 if it considers them to be different, like
2532 \fBdiff\fR(1)\&. If it is set to
2533 \fBfalse\fR, which is the default, then the command is expected to return exit code
2535 regardless of equality\&. Any other exit code causes Git to report a fatal error\&.
2538 \fBdiff\&.ignoreSubmodules\fR
2540 Sets the default value of
2541 \fB\-\-ignore\-submodules\fR\&. Note that this affects only
2544 Porcelain, and not lower level
2548 \fBdiff\-files\fR\&.
2554 also honor this setting when reporting uncommitted changes\&. Setting it to
2556 disables the submodule summary normally shown by
2563 \fBstatus\&.submoduleSummary\fR
2564 is set unless it is overridden by using the
2565 \fB\-\-ignore\-submodules\fR
2566 command\-line option\&. The
2569 commands are not affected by this setting\&. By default this is set to untracked so that any untracked submodules are ignored\&.
2572 \fBdiff\&.mnemonicPrefix\fR
2577 uses a prefix pair that is different from the standard
2581 depending on what is being compared\&. When this configuration is in effect, reverse diff output also swaps the order of the prefixes:
2583 \fBgit\fR \fBdiff\fR
2585 compares the (i)ndex and the (w)ork tree;
2588 \fBgit\fR \fBdiff\fR \fBHEAD\fR
2590 compares a (c)ommit and the (w)ork tree;
2593 \fBgit\fR \fBdiff\fR \fB\-\-cached\fR
2595 compares a (c)ommit and the (i)ndex;
2598 \fBgit\fR \fBdiff\fR \fBHEAD:\fR\fI<file1>\fR \fI<file2>\fR
2600 compares an (o)bject and a (w)ork tree entity;
2603 \fBgit\fR \fBdiff\fR \fB\-\-no\-index\fR \fI<a>\fR \fI<b>\fR
2605 compares two non\-git things
2612 \fBdiff\&.noPrefix\fR
2617 does not show any source or destination prefix\&.
2620 \fBdiff\&.srcPrefix\fR
2625 uses this source prefix\&. Defaults to
2629 \fBdiff\&.dstPrefix\fR
2634 uses this destination prefix\&. Defaults to
2638 \fBdiff\&.relative\fR
2644 does not show changes outside of the directory and show pathnames relative to the current directory\&.
2647 \fBdiff\&.orderFile\fR
2649 File indicating how to order files within a diff\&. See the
2651 option for details\&. If
2652 \fBdiff\&.orderFile\fR
2653 is a relative pathname, it is treated as relative to the top of the working tree\&.
2656 \fBdiff\&.renameLimit\fR
2658 The number of files to consider in the exhaustive portion of copy/rename detection; equivalent to the
2662 \fB\-l\fR\&. If not set, the default value is currently 1000\&. This setting has no effect if rename detection is turned off\&.
2665 \fBdiff\&.renames\fR
2667 Whether and how Git detects renames\&. If set to
2668 \fBfalse\fR, rename detection is disabled\&. If set to
2669 \fBtrue\fR, basic rename detection is enabled\&. If set to
2672 \fBcopy\fR, Git will detect copies, as well\&. Defaults to
2673 \fBtrue\fR\&. Note that this affects only
2679 \fBgit-log\fR(1), and not lower level commands such as
2680 \fBgit-diff-files\fR(1)\&.
2683 \fBdiff\&.suppressBlankEmpty\fR
2685 A boolean to inhibit the standard behavior of printing a space before each empty output line\&. Defaults to
2689 \fBdiff\&.submodule\fR
2691 Specify the format in which differences in submodules are shown\&. The
2693 format just shows the names of the commits at the beginning and end of the range\&. The
2695 format lists the commits in the range like
2696 \fBgit-submodule\fR(1)
2700 format shows an inline diff of the changed contents of the submodule\&. Defaults to
2704 \fBdiff\&.wordRegex\fR
2706 A POSIX Extended Regular Expression used to determine what is a "word" when performing word\-by\-word difference calculations\&. Character sequences that match the regular expression are "words", all other characters are
2711 \fBdiff\&.\fR\fI<driver>\fR\fB\&.command\fR
2713 The custom diff driver command\&. See
2714 \fBgitattributes\fR(5)
2718 \fBdiff\&.\fR\fI<driver>\fR\fB\&.trustExitCode\fR
2720 If this boolean value is set to
2723 \fBdiff\&.\fR\fI<driver>\fR\fB\&.command\fR
2724 command is expected to return exit code 0 if it considers the input files to be equal or 1 if it considers them to be different, like
2725 \fBdiff\fR(1)\&. If it is set to
2726 \fBfalse\fR, which is the default, then the command is expected to return exit code 0 regardless of equality\&. Any other exit code causes Git to report a fatal error\&.
2729 \fBdiff\&.\fR\fI<driver>\fR\fB\&.xfuncname\fR
2731 The regular expression that the diff driver should use to recognize the hunk header\&. A built\-in pattern may also be used\&. See
2732 \fBgitattributes\fR(5)
2736 \fBdiff\&.\fR\fI<driver>\fR\fB\&.binary\fR
2740 to make the diff driver treat files as binary\&. See
2741 \fBgitattributes\fR(5)
2745 \fBdiff\&.\fR\fI<driver>\fR\fB\&.textconv\fR
2747 The command that the diff driver should call to generate the text\-converted version of a file\&. The result of the conversion is used to generate a human\-readable diff\&. See
2748 \fBgitattributes\fR(5)
2752 \fBdiff\&.\fR\fI<driver>\fR\fB\&.wordRegex\fR
2754 The regular expression that the diff driver should use to split words in a line\&. See
2755 \fBgitattributes\fR(5)
2759 \fBdiff\&.\fR\fI<driver>\fR\fB\&.cachetextconv\fR
2763 to make the diff driver cache the text conversion outputs\&. See
2764 \fBgitattributes\fR(5)
2769 Use Araxis Merge (requires a graphical session)
2774 Use Beyond Compare (requires a graphical session)
2779 Use Beyond Compare (requires a graphical session)
2784 Use Beyond Compare (requires a graphical session)
2789 Use Code Compare (requires a graphical session)
2794 Use DeltaWalker (requires a graphical session)
2799 Use DiffMerge (requires a graphical session)
2804 Use Diffuse (requires a graphical session)
2809 Use ECMerge (requires a graphical session)
2814 Use Emacs\*(Aq Emerge
2819 Use ExamDiff Pro (requires a graphical session)
2824 Use Guiffy\(cqs Diff Tool (requires a graphical session)
2829 Use gVim (requires a graphical session)
2834 Use KDiff3 (requires a graphical session)
2839 Use Kompare (requires a graphical session)
2844 Use Meld (requires a graphical session)
2854 Use FileMerge (requires a graphical session)
2859 Use HelixCore P4Merge (requires a graphical session)
2864 Use Sublime Merge (requires a graphical session)
2869 Use TkDiff (requires a graphical session)
2879 Use Visual Studio Code (requires a graphical session)
2884 Use WinMerge (requires a graphical session)
2889 Use xxdiff (requires a graphical session)
2893 \fBdiff\&.indentHeuristic\fR
2897 to disable the default heuristics that shift diff hunk boundaries to make patches easier to read\&.
2900 \fBdiff\&.algorithm\fR
2902 Choose a diff algorithm\&. The variants are as follows:
2904 \fBdefault\fR, \fBmyers\fR
2906 The basic greedy diff algorithm\&. Currently, this is the default\&.
2911 Spend extra time to make sure the smallest possible diff is produced\&.
2916 Use "patience diff" algorithm when generating patches\&.
2921 This algorithm extends the patience algorithm to "support low\-occurrence common elements"\&.
2925 \fBdiff\&.wsErrorHighlight\fR
2927 Highlight whitespace errors in the
2932 lines of the diff\&. Multiple values are separated by comma,
2934 resets previous values,
2941 \fBold,new,context\fR\&. The whitespace errors are colored with
2942 \fBcolor\&.diff\&.whitespace\fR\&. The command line option
2943 \fB\-\-ws\-error\-highlight=\fR\fI<kind>\fR
2944 overrides this setting\&.
2947 \fBdiff\&.colorMoved\fR
2949 If set to either a valid
2953 value, moved lines in a diff are colored differently\&. For details of valid modes see
2954 \fB\-\-color\-moved\fR\&. If simply set to
2956 the default color mode will be used\&. When set to
2957 \fBfalse\fR, moved lines are not colored\&.
2960 \fBdiff\&.colorMovedWS\fR
2962 When moved lines are colored using e\&.g\&. the
2963 \fBdiff\&.colorMoved\fR
2964 setting, this option controls the mode how spaces are treated\&. For details of valid modes see
2965 \fB\-\-color\-moved\-ws\fR
2967 \fBgit-diff\fR(1)\&.
2971 \fBdiff\fR(1), \fBgit-difftool\fR(1), \fBgit-log\fR(1), \fBgitdiffcore\fR(7), \fBgit-format-patch\fR(1), \fBgit-apply\fR(1), \fBgit-show\fR(1)
2974 Part of the \fBgit\fR(1) suite