1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
\r
4 <article lang="en" id="git-diff(1)">
\r
6 <title>git-diff(1)</title>
\r
8 <primary>git-diff(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-diff - Show changes between commits, commit and working tree, etc</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
17 <simpara><emphasis>git diff</emphasis> [<common diff options>] <commit>{0,2} [--] [<path>…]</simpara>
\r
19 <simplesect id="_description">
\r
20 <title>DESCRIPTION</title>
\r
21 <simpara>Show changes between two trees, a tree and the working tree, a
\r
22 tree and the index file, or the index file and the working tree.</simpara>
\r
26 <emphasis>git diff</emphasis> [--options] [--] [<path>…]
\r
30 This form is to view the changes you made relative to
\r
31 the index (staging area for the next commit). In other
\r
32 words, the differences are what you <emphasis>could</emphasis> tell git to
\r
33 further add to the index but you still haven’t. You can
\r
34 stage these changes by using <xref linkend="git-add(1)"/>.
\r
36 <simpara>If exactly two paths are given, and at least one is untracked,
\r
37 compare the two files / directories. This behavior can be
\r
38 forced by --no-index.</simpara>
\r
43 <emphasis>git diff</emphasis> [--options] --cached [<commit>] [--] [<path>…]
\r
47 This form is to view the changes you staged for the next
\r
48 commit relative to the named <commit>. Typically you
\r
49 would want comparison with the latest commit, so if you
\r
50 do not give <commit>, it defaults to HEAD.
\r
51 --staged is a synonym of --cached.
\r
57 <emphasis>git diff</emphasis> [--options] <commit> [--] [<path>…]
\r
61 This form is to view the changes you have in your
\r
62 working tree relative to the named <commit>. You can
\r
63 use HEAD to compare it with the latest commit, or a
\r
64 branch name to compare with the tip of a different
\r
71 <emphasis>git diff</emphasis> [--options] <commit> <commit> [--] [<path>…]
\r
75 This is to view the changes between two arbitrary
\r
82 <emphasis>git diff</emphasis> [--options] <commit>..<commit> [--] [<path>…]
\r
86 This is synonymous to the previous form. If <commit> on
\r
87 one side is omitted, it will have the same effect as
\r
94 <emphasis>git diff</emphasis> [--options] <commit>...<commit> [--] [<path>…]
\r
98 This form is to view the changes on the branch containing
\r
99 and up to the second <commit>, starting at a common ancestor
\r
100 of both <commit>. "git diff A...B" is equivalent to
\r
101 "git diff $(git-merge-base A B) B". You can omit any one
\r
102 of <commit>, which has the same effect as using HEAD instead.
\r
107 <simpara>Just in case if you are doing something exotic, it should be
\r
108 noted that all of the <commit> in the above description, except
\r
109 for the last two forms that use ".." notations, can be any
\r
110 <tree-ish>.</simpara>
\r
111 <simpara>For a more complete list of ways to spell <commit>, see
\r
112 "SPECIFYING REVISIONS" section in <xref linkend="git-rev-parse(1)"/>.
\r
113 However, "diff" is about comparing two <emphasis>endpoints</emphasis>, not ranges,
\r
114 and the range notations ("<commit>..<commit>" and
\r
115 "<commit>...<commit>") do not mean a range as defined in the
\r
116 "SPECIFYING RANGES" section in <xref linkend="git-rev-parse(1)"/>.</simpara>
\r
118 <simplesect id="_options">
\r
119 <title>OPTIONS</title>
\r
130 Generate patch (see section on generating patches).
\r
131 This is the default.
\r
140 --unified=<n>
\r
144 Generate diffs with <n> lines of context instead of
\r
145 the usual three. Implies "-p".
\r
155 Generate the raw format.
\r
166 Synonym for "-p --raw".
\r
176 Generate a diff using the "patience diff" algorithm.
\r
182 --stat[=width[,name-width]]
\r
186 Generate a diffstat. You can override the default
\r
187 output width for 80-column terminal by "--stat=width".
\r
188 The width of the filename part can be controlled by
\r
189 giving another width to it separated by a comma.
\r
199 Similar to --stat, but shows number of added and
\r
200 deleted lines in decimal notation and pathname without
\r
201 abbreviation, to make it more machine friendly. For
\r
202 binary files, outputs two <literal>-</literal> instead of saying
\r
203 <literal>0 0</literal>.
\r
213 Output only the last line of the --stat format containing total
\r
214 number of modified files, as well as number of added and deleted
\r
225 Output the distribution of relative amount of changes (number of lines added or
\r
226 removed) for each sub-directory. Directories with changes below
\r
227 a cut-off percent (3% by default) are not shown. The cut-off percent
\r
228 can be set with "--dirstat=limit". Changes in a child directory is not
\r
229 counted for the parent directory, unless "--cumulative" is used.
\r
235 --dirstat-by-file[=limit]
\r
239 Same as --dirstat, but counts changed files instead of lines.
\r
249 Output a condensed summary of extended header information
\r
250 such as creations, renames and mode changes.
\r
260 Synonym for "-p --stat".
\r
271 NUL-line termination on output. This affects the --raw
\r
272 output field terminator. Also output from commands such
\r
273 as "git-log" will be delimited with NUL between commits.
\r
283 Show only names of changed files.
\r
293 Show only names and status of changed files. See the description
\r
294 of the <literal>--diff-filter</literal> option on what the status letters mean.
\r
314 Turn off colored diff, even when the configuration file
\r
315 gives the default to color output.
\r
321 --color-words[=<regex>]
\r
325 Show colored word diff, i.e., color words which have changed.
\r
326 By default, words are separated by whitespace.
\r
328 <simpara>When a <regex> is specified, every non-overlapping match of the
\r
329 <regex> is considered a word. Anything between these matches is
\r
330 considered whitespace and ignored(!) for the purposes of finding
\r
331 differences. You may want to append <literal>|[^[:space:]]</literal> to your regular
\r
332 expression to make sure that it matches all non-whitespace characters.
\r
333 A match that contains a newline is silently truncated(!) at the
\r
335 <simpara>The regex can also be set via a diff driver or configuration option, see
\r
336 <xref linkend="gitattributes(1)"/> or <xref linkend="git-config(1)"/>. Giving it explicitly
\r
337 overrides any diff driver or configuration setting. Diff drivers
\r
338 override configuration settings.</simpara>
\r
347 Turn off rename detection, even when the configuration
\r
348 file gives the default to do so.
\r
358 Warn if changes introduce trailing whitespace
\r
359 or an indent that uses a space before a tab. Exits with
\r
360 non-zero status if problems are found. Not compatible with
\r
371 Instead of the first handful of characters, show the full
\r
372 pre- and post-image blob object names on the "index"
\r
373 line when generating patch format output.
\r
383 In addition to --full-index, output "binary diff" that
\r
384 can be applied with "git apply".
\r
390 --abbrev[=<n>]
\r
394 Instead of showing the full 40-byte hexadecimal object
\r
395 name in diff-raw format output and diff-tree header
\r
396 lines, show only a partial prefix. This is
\r
397 independent of --full-index option above, which controls
\r
398 the diff-patch output format. Non default number of
\r
399 digits can be specified with --abbrev=<n>.
\r
409 Break complete rewrite changes into pairs of delete and create.
\r
429 Detect copies as well as renames. See also <literal>--find-copies-harder</literal>.
\r
435 --diff-filter=[ACDMRTUXB*]
\r
439 Select only files that are Added (<literal>A</literal>), Copied (<literal>C</literal>),
\r
440 Deleted (<literal>D</literal>), Modified (<literal>M</literal>), Renamed (<literal>R</literal>), have their
\r
441 type (i.e. regular file, symlink, submodule, …) changed (<literal>T</literal>),
\r
442 are Unmerged (<literal>U</literal>), are
\r
443 Unknown (<literal>X</literal>), or have had their pairing Broken (<literal>B</literal>).
\r
444 Any combination of the filter characters may be used.
\r
445 When <literal>*</literal> (All-or-none) is added to the combination, all
\r
446 paths are selected if there is any file that matches
\r
447 other criteria in the comparison; if there is no file
\r
448 that matches other criteria, nothing is selected.
\r
454 --find-copies-harder
\r
458 For performance reasons, by default, <literal>-C</literal> option finds copies only
\r
459 if the original file of the copy was modified in the same
\r
460 changeset. This flag makes the command
\r
461 inspect unmodified files as candidates for the source of
\r
462 copy. This is a very expensive operation for large
\r
463 projects, so use it with caution. Giving more than one
\r
464 <literal>-C</literal> option has the same effect.
\r
474 -M and -C options require O(n^2) processing time where n
\r
475 is the number of potential rename/copy targets. This
\r
476 option prevents rename/copy detection from running if
\r
477 the number of rename/copy targets exceeds the specified
\r
488 Look for differences that contain the change in <string>.
\r
498 When -S finds a change, show all the changes in that
\r
499 changeset, not just the files that contain the change
\r
510 Make the <string> not a plain string but an extended POSIX
\r
517 -O<orderfile>
\r
521 Output the patch in the order specified in the
\r
522 <orderfile>, which has one shell glob pattern per line.
\r
532 Swap two inputs; that is, show differences from index or
\r
533 on-disk file to tree contents.
\r
539 --relative[=<path>]
\r
543 When run from a subdirectory of the project, it can be
\r
544 told to exclude changes outside the directory and show
\r
545 pathnames relative to it with this option. When you are
\r
546 not in a subdirectory (e.g. in a bare repository), you
\r
547 can name which subdirectory to make the output relative
\r
548 to by giving a <path> as an argument.
\r
561 Treat all files as text.
\r
567 --ignore-space-at-eol
\r
571 Ignore changes in whitespace at EOL.
\r
580 --ignore-space-change
\r
584 Ignore changes in amount of whitespace. This ignores whitespace
\r
585 at line end, and considers all other sequences of one or
\r
586 more whitespace characters to be equivalent.
\r
599 Ignore whitespace when comparing lines. This ignores
\r
600 differences even if one line has whitespace where the other
\r
607 --inter-hunk-context=<lines>
\r
611 Show the context between diff hunks, up to the specified number
\r
612 of lines, thereby fusing hunks that are close to each other.
\r
622 Make the program exit with codes similar to diff(1).
\r
623 That is, it exits with 1 if there were differences and
\r
624 0 means no differences.
\r
634 Disable all output of the program. Implies --exit-code.
\r
644 Allow an external diff helper to be executed. If you set an
\r
645 external diff driver with <xref linkend="gitattributes(5)"/>, you need
\r
646 to use this option with <xref linkend="git-log(1)"/> and friends.
\r
656 Disallow external diff drivers.
\r
662 --ignore-submodules
\r
666 Ignore changes to submodules in the diff generation.
\r
672 --src-prefix=<prefix>
\r
676 Show the given source prefix instead of "a/".
\r
682 --dst-prefix=<prefix>
\r
686 Show the given destination prefix instead of "b/".
\r
696 Do not show any source or destination prefix.
\r
701 <simpara>For more detailed explanation on these common options, see also
\r
702 <xref linkend="gitdiffcore(7)"/>.</simpara>
\r
706 <path>…
\r
710 The <paths> parameters, when given, are used to limit
\r
711 the diff to the named paths (you can give directory
\r
712 names and get diff for all files under them).
\r
718 <simplesect id="_output_format">
\r
719 <title>Output format</title>
\r
720 <simpara>The output format from "git-diff-index", "git-diff-tree",
\r
721 "git-diff-files" and "git diff --raw" are very similar.</simpara>
\r
722 <simpara>These commands all compare two sets of things; what is
\r
723 compared differs:</simpara>
\r
727 git-diff-index <tree-ish>
\r
731 compares the <tree-ish> and the files on the filesystem.
\r
737 git-diff-index --cached <tree-ish>
\r
741 compares the <tree-ish> and the index.
\r
747 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…]
\r
751 compares the trees named by the two arguments.
\r
757 git-diff-files [<pattern>…]
\r
761 compares the index and the files on the filesystem.
\r
766 <simpara>An output line is formatted this way:</simpara>
\r
767 <literallayout>in-place edit :100644 100644 bcd1234... 0123456... M file0
\r
768 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
\r
769 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
\r
770 create :000000 100644 0000000... 1234567... A file4
\r
771 delete :100644 000000 1234567... 0000000... D file5
\r
772 unmerged :000000 000000 0000000... 0000000... U file6</literallayout>
\r
773 <simpara>That is, from the left to the right:</simpara>
\r
774 <orderedlist numeration="arabic">
\r
782 mode for "src"; 000000 if creation or unmerged.
\r
792 mode for "dst"; 000000 if deletion or unmerged.
\r
802 sha1 for "src"; 0{40} if creation or unmerged.
\r
812 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
\r
822 status, followed by optional "score" number.
\r
827 a tab or a NUL when <emphasis>-z</emphasis> option is used.
\r
837 a tab or a NUL when <emphasis>-z</emphasis> option is used; only exists for C or R.
\r
842 path for "dst"; only exists for C or R.
\r
847 an LF or a NUL when <emphasis>-z</emphasis> option is used, to terminate the record.
\r
851 <simpara>Possible status letters are:</simpara>
\r
855 A: addition of a file
\r
860 C: copy of a file into a new one
\r
865 D: deletion of a file
\r
870 M: modification of the contents or mode of a file
\r
875 R: renaming of a file
\r
880 T: change in the type of the file
\r
885 U: file is unmerged (you must complete the merge before it can
\r
891 X: "unknown" change type (most probably a bug, please report it)
\r
895 <simpara>Status letters C and R are always followed by a score (denoting the
\r
896 percentage of similarity between the source and target of the move or
\r
897 copy), and are the only ones to be so.</simpara>
\r
898 <simpara><sha1> is shown as all 0’s if a file is new on the filesystem
\r
899 and it is out of sync with the index.</simpara>
\r
900 <simpara>Example:</simpara>
\r
901 <literallayout>:100644 100644 5be4a4...... 000000...... M file.c</literallayout>
\r
902 <simpara>When <literal>-z</literal> option is not used, TAB, LF, and backslash characters
\r
903 in pathnames are represented as <literal>\t</literal>, <literal>\n</literal>, and <literal>\\</literal>,
\r
904 respectively.</simpara>
\r
906 <simplesect id="_diff_format_for_merges">
\r
907 <title>diff format for merges</title>
\r
908 <simpara>"git-diff-tree", "git-diff-files" and "git-diff --raw"
\r
909 can take <emphasis>-c</emphasis> or <emphasis>--cc</emphasis> option
\r
910 to generate diff output also for merge commits. The output differs
\r
911 from the format described above in the following way:</simpara>
\r
912 <orderedlist numeration="arabic">
\r
915 there is a colon for each parent
\r
920 there are more "src" modes and "src" sha1
\r
925 status is concatenated status characters for each parent
\r
930 no optional "score" number
\r
935 single path, only for "dst"
\r
939 <simpara>Example:</simpara>
\r
940 <literallayout>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</literallayout>
\r
941 <simpara>Note that <emphasis>combined diff</emphasis> lists only files which were modified from
\r
942 all parents.</simpara>
\r
944 <simplesect id="_generating_patches_with_p">
\r
945 <title>Generating patches with -p</title>
\r
946 <simpara>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
\r
947 with a <emphasis>-p</emphasis> option, "git diff" without the <emphasis>--raw</emphasis> option, or
\r
948 "git log" with the "-p" option, they
\r
949 do not produce the output described above; instead they produce a
\r
950 patch file. You can customize the creation of such patches via the
\r
951 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</simpara>
\r
952 <simpara>What the -p option produces is slightly different from the traditional
\r
953 diff format.</simpara>
\r
954 <orderedlist numeration="arabic">
\r
957 It is preceded with a "git diff" header, that looks like
\r
960 <literallayout class="monospaced">diff --git a/file1 b/file2</literallayout>
\r
961 <simpara>The <literal>a/</literal> and <literal>b/</literal> filenames are the same unless rename/copy is
\r
962 involved. Especially, even for a creation or a deletion,
\r
963 <literal>/dev/null</literal> is <emphasis>not</emphasis> used in place of <literal>a/</literal> or <literal>b/</literal> filenames.</simpara>
\r
964 <simpara>When rename/copy is involved, <literal>file1</literal> and <literal>file2</literal> show the
\r
965 name of the source file of the rename/copy and the name of
\r
966 the file that rename/copy produces, respectively.</simpara>
\r
970 It is followed by one or more extended header lines:
\r
972 <literallayout class="monospaced">old mode <mode>
\r
973 new mode <mode>
\r
974 deleted file mode <mode>
\r
975 new file mode <mode>
\r
976 copy from <path>
\r
977 copy to <path>
\r
978 rename from <path>
\r
979 rename to <path>
\r
980 similarity index <number>
\r
981 dissimilarity index <number>
\r
982 index <hash>..<hash> <mode></literallayout>
\r
986 TAB, LF, double quote and backslash characters in pathnames
\r
987 are represented as <literal>\t</literal>, <literal>\n</literal>, <literal>\"</literal> and <literal>\\</literal>, respectively.
\r
988 If there is need for such substitution then the whole
\r
989 pathname is put in double quotes.
\r
993 <simpara>The similarity index is the percentage of unchanged lines, and
\r
994 the dissimilarity index is the percentage of changed lines. It
\r
995 is a rounded down integer, followed by a percent sign. The
\r
996 similarity index value of 100% is thus reserved for two equal
\r
997 files, while 100% dissimilarity means that no line from the old
\r
998 file made it into the new one.</simpara>
\r
1000 <simplesect id="_combined_diff_format">
\r
1001 <title>combined diff format</title>
\r
1002 <simpara>"git-diff-tree", "git-diff-files" and "git-diff" can take <emphasis>-c</emphasis> or
\r
1003 <emphasis>--cc</emphasis> option to produce <emphasis>combined diff</emphasis>. For showing a merge commit
\r
1004 with "git log -p", this is the default format.
\r
1005 A <emphasis>combined diff</emphasis> format looks like this:</simpara>
\r
1006 <literallayout>diff --combined describe.c
\r
1007 index fabadb8,cc95eb0..4866510
\r
1010 @@@ -98,20 -98,12 +98,20 @@@
\r
1011 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
\r
1014 - static void describe(char *arg)
\r
1015 -static void describe(struct commit *cmit, int last_one)
\r
1016 ++static void describe(char *arg, int last_one)
\r
1018 + unsigned char sha1[20];
\r
1019 + struct commit *cmit;
\r
1020 struct commit_list *list;
\r
1021 static int initialized = 0;
\r
1022 struct commit_name *n;
\r
1024 + if (get_sha1(arg, sha1) < 0)
\r
1025 + usage(describe_usage);
\r
1026 + cmit = lookup_commit_reference(sha1);
\r
1028 + usage(describe_usage);
\r
1030 if (!initialized) {
\r
1032 for_each_ref(get_name);</literallayout>
\r
1033 <orderedlist numeration="arabic">
\r
1036 It is preceded with a "git diff" header, that looks like
\r
1037 this (when <emphasis>-c</emphasis> option is used):
\r
1039 <literallayout class="monospaced">diff --combined file</literallayout>
\r
1040 <simpara>or like this (when <emphasis>--cc</emphasis> option is used):</simpara>
\r
1041 <literallayout class="monospaced">diff --cc file</literallayout>
\r
1045 It is followed by one or more extended header lines
\r
1046 (this example shows a merge with two parents):
\r
1048 <literallayout class="monospaced">index <hash>,<hash>..<hash>
\r
1049 mode <mode>,<mode>..<mode>
\r
1050 new file mode <mode>
\r
1051 deleted file mode <mode>,<mode></literallayout>
\r
1052 <simpara>The <literal>mode <mode>,<mode>..<mode></literal> line appears only if at least one of
\r
1053 the <mode> is different from the rest. Extended headers with
\r
1054 information about detected contents movement (renames and
\r
1055 copying detection) are designed to work with diff of two
\r
1056 <tree-ish> and are not used by combined diff format.</simpara>
\r
1060 It is followed by two-line from-file/to-file header
\r
1062 <literallayout class="monospaced">--- a/file
\r
1063 +++ b/file</literallayout>
\r
1064 <simpara>Similar to two-line header for traditional <emphasis>unified</emphasis> diff
\r
1065 format, <literal>/dev/null</literal> is used to signal created or deleted
\r
1070 Chunk header format is modified to prevent people from
\r
1071 accidentally feeding it to <literal>patch -p1</literal>. Combined diff format
\r
1072 was created for review of merge commit changes, and was not
\r
1073 meant for apply. The change is similar to the change in the
\r
1074 extended <emphasis>index</emphasis> header:
\r
1076 <literallayout class="monospaced">@@@ <from-file-range> <from-file-range> <to-file-range> @@@</literallayout>
\r
1077 <simpara>There are (number of parents + 1) <literal>@</literal> characters in the chunk
\r
1078 header for combined diff format.</simpara>
\r
1081 <simpara>Unlike the traditional <emphasis>unified</emphasis> diff format, which shows two
\r
1082 files A and B with a single column that has <literal>-</literal> (minus — appears in A but removed in B), <literal>+</literal> (plus — missing in A but
\r
1083 added to B), or <literal>" "</literal> (space — unchanged) prefix, this format
\r
1084 compares two or more files file1, file2,… with one file X, and
\r
1085 shows how X differs from each of fileN. One column for each of
\r
1086 fileN is prepended to the output line to note how X’s line is
\r
1087 different from it.</simpara>
\r
1088 <simpara>A <literal>-</literal> character in the column N means that the line appears in
\r
1089 fileN but it does not appear in the result. A <literal>+</literal> character
\r
1090 in the column N means that the line appears in the result,
\r
1091 and fileN does not have that line (in other words, the line was
\r
1092 added, from the point of view of that parent).</simpara>
\r
1093 <simpara>In the above example output, the function signature was changed
\r
1094 from both files (hence two <literal>-</literal> removals from both file1 and
\r
1095 file2, plus <literal>++</literal> to mean one line that was added does not appear
\r
1096 in either file1 nor file2). Also eight other lines are the same
\r
1097 from file1 but do not appear in file2 (hence prefixed with <literal>+</literal>).</simpara>
\r
1098 <simpara>When shown by <literal>git diff-tree -c</literal>, it compares the parents of a
\r
1099 merge commit with the merge result (i.e. file1..fileN are the
\r
1100 parents). When shown by <literal>git diff-files -c</literal>, it compares the
\r
1101 two unresolved merge parents with the working tree file
\r
1102 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
\r
1103 "their version").</simpara>
\r
1105 <simplesect id="_other_diff_formats">
\r
1106 <title>other diff formats</title>
\r
1107 <simpara>The <literal>--summary</literal> option describes newly added, deleted, renamed and
\r
1108 copied files. The <literal>--stat</literal> option adds diffstat(1) graph to the
\r
1109 output. These options can be combined with other options, such as
\r
1110 <literal>-p</literal>, and are meant for human consumption.</simpara>
\r
1111 <simpara>When showing a change that involves a rename or a copy, <literal>--stat</literal> output
\r
1112 formats the pathnames compactly by combining common prefix and suffix of
\r
1113 the pathnames. For example, a change that moves <literal>arch/i386/Makefile</literal> to
\r
1114 <literal>arch/x86/Makefile</literal> while modifying 4 lines will be shown like this:</simpara>
\r
1115 <literallayout>arch/{i386 => x86}/Makefile | 4 +--</literallayout>
\r
1116 <simpara>The <literal>--numstat</literal> option gives the diffstat(1) information but is designed
\r
1117 for easier machine consumption. An entry in <literal>--numstat</literal> output looks
\r
1118 like this:</simpara>
\r
1119 <literallayout>1 2 README
\r
1120 3 1 arch/{i386 => x86}/Makefile</literallayout>
\r
1121 <simpara>That is, from left to right:</simpara>
\r
1122 <orderedlist numeration="arabic">
\r
1125 the number of added lines;
\r
1135 the number of deleted lines;
\r
1145 pathname (possibly with rename/copy information);
\r
1154 <simpara>When <literal>-z</literal> output option is in effect, the output is formatted this way:</simpara>
\r
1155 <literallayout>1 2 README NUL
\r
1156 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</literallayout>
\r
1157 <simpara>That is:</simpara>
\r
1158 <orderedlist numeration="arabic">
\r
1161 the number of added lines;
\r
1171 the number of deleted lines;
\r
1181 a NUL (only exists if renamed/copied);
\r
1186 pathname in preimage;
\r
1191 a NUL (only exists if renamed/copied);
\r
1196 pathname in postimage (only exists if renamed/copied);
\r
1205 <simpara>The extra <literal>NUL</literal> before the preimage path in renamed case is to allow
\r
1206 scripts that read the output to tell if the current record being read is
\r
1207 a single-path record or a rename/copy record without reading ahead.
\r
1208 After reading added and deleted lines, reading up to <literal>NUL</literal> would yield
\r
1209 the pathname, but if that is <literal>NUL</literal>, the record will show two paths.</simpara>
\r
1211 <simplesect id="_examples">
\r
1212 <title>EXAMPLES</title>
\r
1216 Various ways to check your working tree
\r
1219 <literallayout>$ git diff <co id="CO1-1"/>
\r
1220 $ git diff --cached <co id="CO1-2"/>
\r
1221 $ git diff HEAD <co id="CO1-3"/></literallayout>
\r
1223 <callout arearefs="CO1-1">
\r
1225 Changes in the working tree not yet staged for the next commit.
\r
1228 <callout arearefs="CO1-2">
\r
1230 Changes between the index and your last commit; what you
\r
1231 would be committing if you run "git commit" without "-a" option.
\r
1234 <callout arearefs="CO1-3">
\r
1236 Changes in the working tree since your last commit; what you
\r
1237 would be committing if you run "git commit -a"
\r
1245 Comparing with arbitrary commits
\r
1248 <literallayout>$ git diff test <co id="CO2-1"/>
\r
1249 $ git diff HEAD -- ./test <co id="CO2-2"/>
\r
1250 $ git diff HEAD^ HEAD <co id="CO2-3"/></literallayout>
\r
1252 <callout arearefs="CO2-1">
\r
1254 Instead of using the tip of the current branch, compare with the
\r
1255 tip of "test" branch.
\r
1258 <callout arearefs="CO2-2">
\r
1260 Instead of comparing with the tip of "test" branch, compare with
\r
1261 the tip of the current branch, but limit the comparison to the
\r
1265 <callout arearefs="CO2-3">
\r
1267 Compare the version before the last commit and the last commit.
\r
1275 Comparing branches
\r
1278 <literallayout>$ git diff topic master <co id="CO3-1"/>
\r
1279 $ git diff topic..master <co id="CO3-2"/>
\r
1280 $ git diff topic...master <co id="CO3-3"/></literallayout>
\r
1282 <callout arearefs="CO3-1">
\r
1284 Changes between the tips of the topic and the master branches.
\r
1287 <callout arearefs="CO3-2">
\r
1292 <callout arearefs="CO3-3">
\r
1294 Changes that occurred on the master branch since when the topic
\r
1295 branch was started off it.
\r
1303 Limiting the diff output
\r
1306 <literallayout>$ git diff --diff-filter=MRC <co id="CO4-1"/>
\r
1307 $ git diff --name-status <co id="CO4-2"/>
\r
1308 $ git diff arch/i386 include/asm-i386 <co id="CO4-3"/></literallayout>
\r
1310 <callout arearefs="CO4-1">
\r
1312 Show only modification, rename and copy, but not addition
\r
1316 <callout arearefs="CO4-2">
\r
1318 Show only names and the nature of change, but not actual
\r
1322 <callout arearefs="CO4-3">
\r
1324 Limit diff output to named subtrees.
\r
1332 Munging the diff output
\r
1335 <literallayout>$ git diff --find-copies-harder -B -C <co id="CO5-1"/>
\r
1336 $ git diff -R <co id="CO5-2"/></literallayout>
\r
1338 <callout arearefs="CO5-1">
\r
1340 Spend extra cycles to find renames, copies and complete
\r
1341 rewrites (very expensive).
\r
1344 <callout arearefs="CO5-2">
\r
1346 Output diff in reverse.
\r
1354 <simplesect id="_author">
\r
1355 <title>Author</title>
\r
1356 <simpara>Written by Linus Torvalds <<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>></simpara>
\r
1358 <simplesect id="_documentation">
\r
1359 <title>Documentation</title>
\r
1360 <simpara>Documentation by Junio C Hamano and the git-list <<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>>.</simpara>
\r
1362 <simplesect id="_git">
\r
1363 <title>GIT</title>
\r
1364 <simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
\r