1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.2.5" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-diff(
1)
</title>
312 git-diff(
1) Manual Page
315 <div class=
"sectionbody">
317 Show changes between commits, commit and working tree, etc
322 <div class=
"sectionbody">
323 <div class=
"para"><p><em>git diff
</em> [
<common diff options
>]
<commit
>{
0,
2} [--] [
<path
>…]
</p></div>
325 <h2 id=
"_description">DESCRIPTION
</h2>
326 <div class=
"sectionbody">
327 <div class=
"para"><p>Show changes between two trees, a tree and the working tree, a
328 tree and the index file, or the index file and the working tree.
</p></div>
329 <div class=
"vlist"><dl>
331 <em>git diff
</em> [--options] [--] [
<path
>…]
335 This form is to view the changes you made relative to
336 the index (staging area for the next commit). In other
337 words, the differences are what you _could_ tell git to
338 further add to the index but you still haven't. You can
339 stage these changes by using
<a href=
"git-add.html">git-add(
1)
</a>.
341 <div class=
"para"><p>If exactly two paths are given, and at least one is untracked,
342 compare the two files / directories. This behavior can be
343 forced by --no-index.
</p></div>
346 <em>git diff
</em> [--options] --cached [
<commit
>] [--] [
<path
>…]
350 This form is to view the changes you staged for the next
351 commit relative to the named
<commit
>. Typically you
352 would want comparison with the latest commit, so if you
353 do not give
<commit
>, it defaults to HEAD.
354 --staged is a synonym of --cached.
358 <em>git diff
</em> [--options]
<commit
> [--] [
<path
>…]
362 This form is to view the changes you have in your
363 working tree relative to the named
<commit
>. You can
364 use HEAD to compare it with the latest commit, or a
365 branch name to compare with the tip of a different
370 <em>git diff
</em> [--options]
<commit
> <commit
> [--] [
<path
>…]
374 This is to view the changes between two arbitrary
379 <em>git diff
</em> [--options]
<commit
>..
<commit
> [--] [
<path
>…]
383 This is synonymous to the previous form. If
<commit
> on
384 one side is omitted, it will have the same effect as
389 <em>git diff
</em> [--options]
<commit
>...
<commit
> [--] [
<path
>…]
393 This form is to view the changes on the branch containing
394 and up to the second
<commit
>, starting at a common ancestor
395 of both
<commit
>.
"git diff A...B" is equivalent to
396 "git diff $(git-merge-base A B) B". You can omit any one
397 of
<commit
>, which has the same effect as using HEAD instead.
401 <div class=
"para"><p>Just in case if you are doing something exotic, it should be
402 noted that all of the
<commit
> in the above description, except
403 for the last two forms that use
".." notations, can be any
404 <tree-ish
>.
</p></div>
405 <div class=
"para"><p>For a more complete list of ways to spell
<commit
>, see
406 "SPECIFYING REVISIONS" section in
<a href=
"git-rev-parse.html">git-rev-parse(
1)
</a>.
407 However,
"diff" is about comparing two _endpoints_, not ranges,
408 and the range notations (
"<commit>..<commit>" and
409 "<commit>...<commit>") do not mean a range as defined in the
410 "SPECIFYING RANGES" section in
<a href=
"git-rev-parse.html">git-rev-parse(
1)
</a>.
</p></div>
412 <h2 id=
"_options">OPTIONS
</h2>
413 <div class=
"sectionbody">
414 <div class=
"vlist"><dl>
423 Generate patch (see section on generating patches).
435 Generate diffs with
<n
> lines of context instead of
445 Generate the raw format.
454 Synonym for
<tt>-p --raw
</tt>.
462 Generate a diff using the
"patience diff" algorithm.
466 --stat[=width[,name-width]]
470 Generate a diffstat. You can override the default
471 output width for
80-column terminal by
<tt>--stat=width
</tt>.
472 The width of the filename part can be controlled by
473 giving another width to it separated by a comma.
481 Similar to
<tt>--stat
</tt>, but shows number of added and
482 deleted lines in decimal notation and pathname without
483 abbreviation, to make it more machine friendly. For
484 binary files, outputs two
<tt>-
</tt> instead of saying
493 Output only the last line of the
<tt>--stat
</tt> format containing total
494 number of modified files, as well as number of added and deleted
503 Output the distribution of relative amount of changes (number of lines added or
504 removed) for each sub-directory. Directories with changes below
505 a cut-off percent (
3% by default) are not shown. The cut-off percent
506 can be set with
<tt>--dirstat=limit
</tt>. Changes in a child directory is not
507 counted for the parent directory, unless
<tt>--cumulative
</tt> is used.
511 --dirstat-by-file[=limit]
515 Same as
<tt>--dirstat
</tt>, but counts changed files instead of lines.
523 Output a condensed summary of extended header information
524 such as creations, renames and mode changes.
532 Synonym for
<tt>-p --stat
</tt>.
540 When
<tt>--raw
</tt> or
<tt>--numstat
</tt> has been given, do not munge
541 pathnames and use NULs as output field terminators.
543 <div class=
"para"><p>Without this option, each pathname output will have TAB, LF, double quotes,
544 and backslash characters replaced with
<tt>\t
</tt>,
<tt>\n
</tt>,
<tt>\
"</tt>, and <tt>\\</tt>,
545 respectively, and the pathname will be enclosed in double quotes if
546 any of those replacements occurred.</p></div>
553 Show only names of changed files.
561 Show only names and status of changed files. See the description
562 of the <tt>--diff-filter</tt> option on what the status letters mean.
566 --submodule[=<format>]
570 Chose the output format for submodule differences. <format> can be one of
571 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
572 is used when this option is not given. <em>log</em> is the default value for this
573 option and lists the commits in that commit range like the <em>summary</em>
574 option of <a href="git-submodule.html
">git-submodule(1)</a> does.
578 --color[=<when>]
583 The value must be always (the default), never, or auto.
591 Turn off colored diff, even when the configuration file
592 gives the default to color output.
593 Same as <tt>--color=never</tt>.
597 --color-words[=<regex>]
601 Show colored word diff, i.e., color words which have changed.
602 By default, words are separated by whitespace.
604 <div class="para
"><p>When a <regex> is specified, every non-overlapping match of the
605 <regex> is considered a word. Anything between these matches is
606 considered whitespace and ignored(!) for the purposes of finding
607 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
608 expression to make sure that it matches all non-whitespace characters.
609 A match that contains a newline is silently truncated(!) at the
611 <div class="para
"><p>The regex can also be set via a diff driver or configuration option, see
612 <a href="gitattributes.html
">gitattributes(1)</a> or <a href="git-config.html
">git-config(1)</a>. Giving it explicitly
613 overrides any diff driver or configuration setting. Diff drivers
614 override configuration settings.</p></div>
621 Turn off rename detection, even when the configuration
622 file gives the default to do so.
630 Warn if changes introduce trailing whitespace
631 or an indent that uses a space before a tab. Exits with
632 non-zero status if problems are found. Not compatible with
641 Instead of the first handful of characters, show the full
642 pre- and post-image blob object names on the "index
"
643 line when generating patch format output.
651 In addition to <tt>--full-index</tt>, output a binary diff that
652 can be applied with <tt>git-apply</tt>.
660 Instead of showing the full 40-byte hexadecimal object
661 name in diff-raw format output and diff-tree header
662 lines, show only a partial prefix. This is
663 independent of the <tt>--full-index</tt> option above, which controls
664 the diff-patch output format. Non default number of
665 digits can be specified with <tt>--abbrev=<n></tt>.
673 Break complete rewrite changes into pairs of delete and create.
689 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
693 --diff-filter=[ACDMRTUXB*]
697 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
698 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
699 type (i.e. regular file, symlink, submodule, …) changed (<tt>T</tt>),
700 are Unmerged (<tt>U</tt>), are
701 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
702 Any combination of the filter characters may be used.
703 When <tt>*</tt> (All-or-none) is added to the combination, all
704 paths are selected if there is any file that matches
705 other criteria in the comparison; if there is no file
706 that matches other criteria, nothing is selected.
714 For performance reasons, by default, <tt>-C</tt> option finds copies only
715 if the original file of the copy was modified in the same
716 changeset. This flag makes the command
717 inspect unmodified files as candidates for the source of
718 copy. This is a very expensive operation for large
719 projects, so use it with caution. Giving more than one
720 <tt>-C</tt> option has the same effect.
728 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
729 is the number of potential rename/copy targets. This
730 option prevents rename/copy detection from running if
731 the number of rename/copy targets exceeds the specified
740 Look for differences that introduce or remove an instance of
741 <string>. Note that this is different than the string simply
742 appearing in diff output; see the <em>pickaxe</em> entry in
743 <a href="gitdiffcore.html
">gitdiffcore(7)</a> for more details.
751 When <tt>-S</tt> finds a change, show all the changes in that
752 changeset, not just the files that contain the change
761 Make the <string> not a plain string but an extended POSIX
770 Output the patch in the order specified in the
771 <orderfile>, which has one shell glob pattern per line.
779 Swap two inputs; that is, show differences from index or
780 on-disk file to tree contents.
784 --relative[=<path>]
788 When run from a subdirectory of the project, it can be
789 told to exclude changes outside the directory and show
790 pathnames relative to it with this option. When you are
791 not in a subdirectory (e.g. in a bare repository), you
792 can name which subdirectory to make the output relative
793 to by giving a <path> as an argument.
804 Treat all files as text.
808 --ignore-space-at-eol
812 Ignore changes in whitespace at EOL.
819 --ignore-space-change
823 Ignore changes in amount of whitespace. This ignores whitespace
824 at line end, and considers all other sequences of one or
825 more whitespace characters to be equivalent.
836 Ignore whitespace when comparing lines. This ignores
837 differences even if one line has whitespace where the other
842 --inter-hunk-context=<lines>
846 Show the context between diff hunks, up to the specified number
847 of lines, thereby fusing hunks that are close to each other.
855 Make the program exit with codes similar to diff(1).
856 That is, it exits with 1 if there were differences and
857 0 means no differences.
865 Disable all output of the program. Implies <tt>--exit-code</tt>.
873 Allow an external diff helper to be executed. If you set an
874 external diff driver with <a href="gitattributes.html
">gitattributes(5)</a>, you need
875 to use this option with <a href="git-log.html
">git-log(1)</a> and friends.
883 Disallow external diff drivers.
891 Ignore changes to submodules in the diff generation.
895 --src-prefix=<prefix>
899 Show the given source prefix instead of "a/
".
903 --dst-prefix=<prefix>
907 Show the given destination prefix instead of "b/
".
915 Do not show any source or destination prefix.
919 <div class="para
"><p>For more detailed explanation on these common options, see also
920 <a href="gitdiffcore.html
">gitdiffcore(7)</a>.</p></div>
921 <div class="vlist
"><dl>
927 The <paths> parameters, when given, are used to limit
928 the diff to the named paths (you can give directory
929 names and get diff for all files under them).
934 <h2 id="_raw_output_format
">Raw output format</h2>
935 <div class="sectionbody
">
936 <div class="para
"><p>The raw output format from "git-diff-index
", "git-diff-tree
",
937 "git-diff-files
" and "git diff --raw
" are very similar.</p></div>
938 <div class="para
"><p>These commands all compare two sets of things; what is
939 compared differs:</p></div>
940 <div class="vlist
"><dl>
942 git-diff-index <tree-ish>
946 compares the <tree-ish> and the files on the filesystem.
950 git-diff-index --cached <tree-ish>
954 compares the <tree-ish> and the index.
958 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…]
962 compares the trees named by the two arguments.
966 git-diff-files [<pattern>…]
970 compares the index and the files on the filesystem.
974 <div class="para
"><p>The "git-diff-tree
" command begins its output by printing the hash of
975 what is being compared. After that, all the commands print one output
976 line per changed file.</p></div>
977 <div class="para
"><p>An output line is formatted this way:</p></div>
978 <div class="listingblock
">
979 <div class="content
">
980 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
981 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
982 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
983 create :000000 100644 0000000... 1234567... A file4
984 delete :100644 000000 1234567... 0000000... D file5
985 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
987 <div class="para
"><p>That is, from the left to the right:</p></div>
988 <div class="olist
"><ol>
996 mode for "src
"; 000000 if creation or unmerged.
1006 mode for "dst
"; 000000 if deletion or unmerged.
1016 sha1 for "src
"; 0{40} if creation or unmerged.
1026 sha1 for "dst
"; 0{40} if creation, unmerged or "look at work tree
".
1036 status, followed by optional "score
" number.
1041 a tab or a NUL when <em>-z</em> option is used.
1051 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1056 path for "dst
"; only exists for C or R.
1061 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1065 <div class="para
"><p>Possible status letters are:</p></div>
1066 <div class="ilist
"><ul>
1069 A: addition of a file
1074 C: copy of a file into a new one
1079 D: deletion of a file
1084 M: modification of the contents or mode of a file
1089 R: renaming of a file
1094 T: change in the type of the file
1099 U: file is unmerged (you must complete the merge before it can
1105 X: "unknown
" change type (most probably a bug, please report it)
1109 <div class="para
"><p>Status letters C and R are always followed by a score (denoting the
1110 percentage of similarity between the source and target of the move or
1111 copy), and are the only ones to be so.</p></div>
1112 <div class="para
"><p><sha1> is shown as all 0's if a file is new on the filesystem
1113 and it is out of sync with the index.</p></div>
1114 <div class="para
"><p>Example:</p></div>
1115 <div class="listingblock
">
1116 <div class="content
">
1117 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1119 <div class="para
"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1120 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1121 respectively.</p></div>
1123 <h2 id="_diff_format_for_merges
">diff format for merges</h2>
1124 <div class="sectionbody
">
1125 <div class="para
"><p>"git-diff-tree
", "git-diff-files
" and "git-diff --raw
"
1126 can take <em>-c</em> or <em>--cc</em> option
1127 to generate diff output also for merge commits. The output differs
1128 from the format described above in the following way:</p></div>
1129 <div class="olist
"><ol>
1132 there is a colon for each parent
1137 there are more "src
" modes and "src
" sha1
1142 status is concatenated status characters for each parent
1147 no optional "score
" number
1152 single path, only for "dst
"
1156 <div class="para
"><p>Example:</p></div>
1157 <div class="listingblock
">
1158 <div class="content
">
1159 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1161 <div class="para
"><p>Note that <em>combined diff</em> lists only files which were modified from
1162 all parents.</p></div>
1164 <h2 id="_generating_patches_with_p
">Generating patches with -p</h2>
1165 <div class="sectionbody
">
1166 <div class="para
"><p>When "git-diff-index
", "git-diff-tree
", or "git-diff-files
" are run
1167 with a <em>-p</em> option, "git diff
" without the <em>--raw</em> option, or
1168 "git log
" with the "-p
" option, they
1169 do not produce the output described above; instead they produce a
1170 patch file. You can customize the creation of such patches via the
1171 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1172 <div class="para
"><p>What the -p option produces is slightly different from the traditional
1173 diff format.</p></div>
1174 <div class="olist
"><ol>
1177 It is preceded with a "git diff
" header, that looks like
1180 <div class="literalblock
">
1181 <div class="content
">
1182 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1184 <div class="para
"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1185 involved. Especially, even for a creation or a deletion,
1186 <tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1187 <div class="para
"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1188 name of the source file of the rename/copy and the name of
1189 the file that rename/copy produces, respectively.</p></div>
1193 It is followed by one or more extended header lines:
1195 <div class="literalblock
">
1196 <div class="content
">
1197 <pre><tt>old mode <mode>
1198 new mode <mode>
1199 deleted file mode <mode>
1200 new file mode <mode>
1201 copy from <path>
1202 copy to <path>
1203 rename from <path>
1204 rename to <path>
1205 similarity index <number>
1206 dissimilarity index <number>
1207 index <hash>..<hash> <mode></tt></pre>
1212 TAB, LF, double quote and backslash characters in pathnames
1213 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and
<tt>\\
</tt>, respectively.
1214 If there is need for such substitution then the whole
1215 pathname is put in double quotes.
1219 <div class=
"para"><p>The similarity index is the percentage of unchanged lines, and
1220 the dissimilarity index is the percentage of changed lines. It
1221 is a rounded down integer, followed by a percent sign. The
1222 similarity index value of
100% is thus reserved for two equal
1223 files, while
100% dissimilarity means that no line from the old
1224 file made it into the new one.
</p></div>
1226 <h2 id=
"_combined_diff_format">combined diff format
</h2>
1227 <div class=
"sectionbody">
1228 <div class=
"para"><p>"git-diff-tree",
"git-diff-files" and
"git-diff" can take
<em>-c
</em> or
1229 <em>--cc
</em> option to produce
<em>combined diff
</em>. For showing a merge commit
1230 with
"git log -p", this is the default format; you can force showing
1231 full diff with the
<em>-m
</em> option.
1232 A
<em>combined diff
</em> format looks like this:
</p></div>
1233 <div class=
"listingblock">
1234 <div class=
"content">
1235 <pre><tt>diff --combined describe.c
1236 index fabadb8,cc95eb0.
.4866510
1239 @@@ -
98,
20 -
98,
12 +
98,
20 @@@
1240 return (a_date
> b_date) ? -
1 : (a_date == b_date) ?
0 :
1;
1243 - static void describe(char *arg)
1244 -static void describe(struct commit *cmit, int last_one)
1245 ++static void describe(char *arg, int last_one)
1247 + unsigned char sha1[
20];
1248 + struct commit *cmit;
1249 struct commit_list *list;
1250 static int initialized =
0;
1251 struct commit_name *n;
1253 + if (get_sha1(arg, sha1)
< 0)
1254 + usage(describe_usage);
1255 + cmit = lookup_commit_reference(sha1);
1257 + usage(describe_usage);
1261 for_each_ref(get_name);
</tt></pre>
1263 <div class=
"olist"><ol>
1266 It is preceded with a
"git diff" header, that looks like
1267 this (when
<em>-c
</em> option is used):
1269 <div class=
"literalblock">
1270 <div class=
"content">
1271 <pre><tt>diff --combined file
</tt></pre>
1273 <div class=
"para"><p>or like this (when
<em>--cc
</em> option is used):
</p></div>
1274 <div class=
"literalblock">
1275 <div class=
"content">
1276 <pre><tt>diff --cc file
</tt></pre>
1281 It is followed by one or more extended header lines
1282 (this example shows a merge with two parents):
1284 <div class=
"literalblock">
1285 <div class=
"content">
1286 <pre><tt>index
<hash
>,
<hash
>..
<hash
>
1287 mode
<mode
>,
<mode
>..
<mode
>
1288 new file mode
<mode
>
1289 deleted file mode
<mode
>,
<mode
></tt></pre>
1291 <div class=
"para"><p>The
<tt>mode
<mode
>,
<mode
>..
<mode
></tt> line appears only if at least one of
1292 the
<mode
> is different from the rest. Extended headers with
1293 information about detected contents movement (renames and
1294 copying detection) are designed to work with diff of two
1295 <tree-ish
> and are not used by combined diff format.
</p></div>
1299 It is followed by two-line from-file/to-file header
1301 <div class=
"literalblock">
1302 <div class=
"content">
1304 +++ b/file
</tt></pre>
1306 <div class=
"para"><p>Similar to two-line header for traditional
<em>unified
</em> diff
1307 format,
<tt>/dev/null
</tt> is used to signal created or deleted
1312 Chunk header format is modified to prevent people from
1313 accidentally feeding it to
<tt>patch -p1
</tt>. Combined diff format
1314 was created for review of merge commit changes, and was not
1315 meant for apply. The change is similar to the change in the
1316 extended
<em>index
</em> header:
1318 <div class=
"literalblock">
1319 <div class=
"content">
1320 <pre><tt>@@@
<from-file-range
> <from-file-range
> <to-file-range
> @@@
</tt></pre>
1322 <div class=
"para"><p>There are (number of parents +
1)
<tt>@
</tt> characters in the chunk
1323 header for combined diff format.
</p></div>
1326 <div class=
"para"><p>Unlike the traditional
<em>unified
</em> diff format, which shows two
1327 files A and B with a single column that has
<tt>-
</tt> (minus
—
1328 appears in A but removed in B),
<tt>+
</tt> (plus
— missing in A but
1329 added to B), or
<tt>" "</tt> (space
— unchanged) prefix, this format
1330 compares two or more files file1, file2,
… with one file X, and
1331 shows how X differs from each of fileN. One column for each of
1332 fileN is prepended to the output line to note how X's line is
1333 different from it.
</p></div>
1334 <div class=
"para"><p>A
<tt>-
</tt> character in the column N means that the line appears in
1335 fileN but it does not appear in the result. A
<tt>+
</tt> character
1336 in the column N means that the line appears in the result,
1337 and fileN does not have that line (in other words, the line was
1338 added, from the point of view of that parent).
</p></div>
1339 <div class=
"para"><p>In the above example output, the function signature was changed
1340 from both files (hence two
<tt>-
</tt> removals from both file1 and
1341 file2, plus
<tt>++
</tt> to mean one line that was added does not appear
1342 in either file1 nor file2). Also eight other lines are the same
1343 from file1 but do not appear in file2 (hence prefixed with
<tt>+</tt>).
</p></div>
1344 <div class=
"para"><p>When shown by
<tt>git diff-tree -c
</tt>, it compares the parents of a
1345 merge commit with the merge result (i.e. file1..fileN are the
1346 parents). When shown by
<tt>git diff-files -c
</tt>, it compares the
1347 two unresolved merge parents with the working tree file
1348 (i.e. file1 is stage
2 aka
"our version", file2 is stage
3 aka
1349 "their version").
</p></div>
1351 <h2 id=
"_other_diff_formats">other diff formats
</h2>
1352 <div class=
"sectionbody">
1353 <div class=
"para"><p>The
<tt>--summary
</tt> option describes newly added, deleted, renamed and
1354 copied files. The
<tt>--stat
</tt> option adds diffstat(
1) graph to the
1355 output. These options can be combined with other options, such as
1356 <tt>-p
</tt>, and are meant for human consumption.
</p></div>
1357 <div class=
"para"><p>When showing a change that involves a rename or a copy,
<tt>--stat
</tt> output
1358 formats the pathnames compactly by combining common prefix and suffix of
1359 the pathnames. For example, a change that moves
<tt>arch/i386/Makefile
</tt> to
1360 <tt>arch/x86/Makefile
</tt> while modifying
4 lines will be shown like this:
</p></div>
1361 <div class=
"listingblock">
1362 <div class=
"content">
1363 <pre><tt>arch/{i386 =
> x86}/Makefile |
4 +--
</tt></pre>
1365 <div class=
"para"><p>The
<tt>--numstat
</tt> option gives the diffstat(
1) information but is designed
1366 for easier machine consumption. An entry in
<tt>--numstat
</tt> output looks
1367 like this:
</p></div>
1368 <div class=
"listingblock">
1369 <div class=
"content">
1371 3 1 arch/{i386 =
> x86}/Makefile
</tt></pre>
1373 <div class=
"para"><p>That is, from left to right:
</p></div>
1374 <div class=
"olist"><ol>
1377 the number of added lines;
1387 the number of deleted lines;
1397 pathname (possibly with rename/copy information);
1406 <div class=
"para"><p>When
<tt>-z
</tt> output option is in effect, the output is formatted this way:
</p></div>
1407 <div class=
"listingblock">
1408 <div class=
"content">
1409 <pre><tt>1 2 README NUL
1410 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
</tt></pre>
1412 <div class=
"para"><p>That is:
</p></div>
1413 <div class=
"olist"><ol>
1416 the number of added lines;
1426 the number of deleted lines;
1436 a NUL (only exists if renamed/copied);
1441 pathname in preimage;
1446 a NUL (only exists if renamed/copied);
1451 pathname in postimage (only exists if renamed/copied);
1460 <div class=
"para"><p>The extra
<tt>NUL
</tt> before the preimage path in renamed case is to allow
1461 scripts that read the output to tell if the current record being read is
1462 a single-path record or a rename/copy record without reading ahead.
1463 After reading added and deleted lines, reading up to
<tt>NUL
</tt> would yield
1464 the pathname, but if that is
<tt>NUL
</tt>, the record will show two paths.
</p></div>
1466 <h2 id=
"_examples">EXAMPLES
</h2>
1467 <div class=
"sectionbody">
1468 <div class=
"vlist"><dl>
1470 Various ways to check your working tree
1473 <div class=
"listingblock">
1474 <div class=
"content">
1475 <pre><tt>$ git diff
<b>(
1)
</b>
1476 $ git diff --cached
<b>(
2)
</b>
1477 $ git diff HEAD
<b>(
3)
</b></tt></pre>
1479 <div class=
"colist"><ol>
1482 Changes in the working tree not yet staged for the next commit.
1487 Changes between the index and your last commit; what you
1488 would be committing if you run
"git commit" without
"-a" option.
1493 Changes in the working tree since your last commit; what you
1494 would be committing if you run
"git commit -a"
1500 Comparing with arbitrary commits
1503 <div class=
"listingblock">
1504 <div class=
"content">
1505 <pre><tt>$ git diff test
<b>(
1)
</b>
1506 $ git diff HEAD -- ./test
<b>(
2)
</b>
1507 $ git diff HEAD^ HEAD
<b>(
3)
</b></tt></pre>
1509 <div class=
"colist"><ol>
1512 Instead of using the tip of the current branch, compare with the
1513 tip of
"test" branch.
1518 Instead of comparing with the tip of
"test" branch, compare with
1519 the tip of the current branch, but limit the comparison to the
1525 Compare the version before the last commit and the last commit.
1534 <div class=
"listingblock">
1535 <div class=
"content">
1536 <pre><tt>$ git diff topic master
<b>(
1)
</b>
1537 $ git diff topic..master
<b>(
2)
</b>
1538 $ git diff topic...master
<b>(
3)
</b></tt></pre>
1540 <div class=
"colist"><ol>
1543 Changes between the tips of the topic and the master branches.
1553 Changes that occurred on the master branch since when the topic
1554 branch was started off it.
1560 Limiting the diff output
1563 <div class=
"listingblock">
1564 <div class=
"content">
1565 <pre><tt>$ git diff --diff-filter=MRC
<b>(
1)
</b>
1566 $ git diff --name-status
<b>(
2)
</b>
1567 $ git diff arch/i386 include/asm-i386
<b>(
3)
</b></tt></pre>
1569 <div class=
"colist"><ol>
1572 Show only modification, rename and copy, but not addition
1578 Show only names and the nature of change, but not actual
1584 Limit diff output to named subtrees.
1590 Munging the diff output
1593 <div class=
"listingblock">
1594 <div class=
"content">
1595 <pre><tt>$ git diff --find-copies-harder -B -C
<b>(
1)
</b>
1596 $ git diff -R
<b>(
2)
</b></tt></pre>
1598 <div class=
"colist"><ol>
1601 Spend extra cycles to find renames, copies and complete
1602 rewrites (very expensive).
1607 Output diff in reverse.
1614 <h2 id=
"_see_also">SEE ALSO
</h2>
1615 <div class=
"sectionbody">
1616 <div class=
"vlist"><dl>
1618 <a href=
"git-difftool.html">git-difftool(
1)
</a>
1622 Show changes using common diff tools
1627 <h2 id=
"_author">Author
</h2>
1628 <div class=
"sectionbody">
1629 <div class=
"para"><p>Written by Linus Torvalds
<torvalds@osdl.org
></p></div>
1631 <h2 id=
"_documentation">Documentation
</h2>
1632 <div class=
"sectionbody">
1633 <div class=
"para"><p>Documentation by Junio C Hamano and the git-list
<git@vger.kernel.org
>.
</p></div>
1635 <h2 id=
"_git">GIT
</h2>
1636 <div class=
"sectionbody">
1637 <div class=
"para"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1640 <div id=
"footer-text">
1641 Last updated
2010-
03-
25 00:
38:
22 UTC