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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

70       -p, -u, --patch
71           Generate patch (see section on generating patches). This is the
72           default.
73
74       -U<n>, --unified=<n>
75           Generate diffs with <n> lines of context instead of the usual
76           three. Implies -p.
77
78       --raw
79           Generate the raw format.
80
81       --patch-with-raw
82           Synonym for -p --raw.
83
84       --patience
85           Generate a diff using the "patience diff" algorithm.
86
87       --stat[=<width>[,<name-width>]]
88           Generate a diffstat. You can override the default output width for
89           80-column terminal by --stat=<width>. The width of the filename
90           part can be controlled by giving another width to it separated by a
91           comma.
92
93       --numstat
94           Similar to --stat, but shows number of added and deleted lines in
95           decimal notation and pathname without abbreviation, to make it more
96           machine friendly. For binary files, outputs two - instead of saying
97           0 0.
98
99       --shortstat
100           Output only the last line of the --stat format containing total
101           number of modified files, as well as number of added and deleted
102           lines.
103
104       --dirstat[=<limit>]
105           Output the distribution of relative amount of changes (number of
106           lines added or removed) for each sub-directory. Directories with
107           changes below a cut-off percent (3% by default) are not shown. The
108           cut-off percent can be set with --dirstat=<limit>. Changes in a
109           child directory are not counted for the parent directory, unless
110           --cumulative is used.
111
112       --dirstat-by-file[=<limit>]
113           Same as --dirstat, but counts changed files instead of lines.
114
115       --summary
116           Output a condensed summary of extended header information such as
117           creations, renames and mode changes.
118
119       --patch-with-stat
120           Synonym for -p --stat.
121
122       -z
123           When --raw, --numstat, --name-only or --name-status has been given,
124           do not munge pathnames and use NULs as output field terminators.
125
126           Without this option, each pathname output will have TAB, LF, double
127           quotes, and backslash characters replaced with \t, \n, \", and \\,
128           respectively, and the pathname will be enclosed in double quotes if
129           any of those replacements occurred.
130
131       --name-only
132           Show only names of changed files.
133
134       --name-status
135           Show only names and status of changed files. See the description of
136           the --diff-filter option on what the status letters mean.
137
138       --submodule[=<format>]
139           Chose the output format for submodule differences. <format> can be
140           one of short and log.  short just shows pairs of commit names, this
141           format is used when this option is not given.  log is the default
142           value for this option and lists the commits in that commit range
143           like the summary option of git-submodule(1) does.
144
145       --color[=<when>]
146           Show colored diff. The value must be always (the default), never,
147           or auto.
148
149       --no-color
150           Turn off colored diff, even when the configuration file gives the
151           default to color output. Same as --color=never.
152
153       --word-diff[=<mode>]
154           Show a word diff, using the <mode> to delimit changed words. By
155           default, words are delimited by whitespace; see --word-diff-regex
156           below. The <mode> defaults to plain, and must be one of:
157
158           color
159               Highlight changed words using only colors. Implies --color.
160
161           plain
162               Show words as [-removed-] and {added}. Makes no attempts to
163               escape the delimiters if they appear in the input, so the
164               output may be ambiguous.
165
166           porcelain
167               Use a special line-based format intended for script
168               consumption. Added/removed/unchanged runs are printed in the
169               usual unified diff format, starting with a +/-/` ` character at
170               the beginning of the line and extending to the end of the line.
171               Newlines in the input are represented by a tilde ~ on a line of
172               its own.
173
174           none
175               Disable word diff again.
176
177           Note that despite the name of the first mode, color is used to
178           highlight the changed parts in all modes if enabled.
179
180       --word-diff-regex=<regex>
181           Use <regex> to decide what a word is, instead of considering runs
182           of non-whitespace to be a word. Also implies --word-diff unless it
183           was already enabled.
184
185           Every non-overlapping match of the <regex> is considered a word.
186           Anything between these matches is considered whitespace and
187           ignored(!) for the purposes of finding differences. You may want to
188           append |[^[:space:]] to your regular expression to make sure that
189           it matches all non-whitespace characters. A match that contains a
190           newline is silently truncated(!) at the newline.
191
192           The regex can also be set via a diff driver or configuration
193           option, see gitattributes(1) or git-config(1). Giving it explicitly
194           overrides any diff driver or configuration setting. Diff drivers
195           override configuration settings.
196
197       --color-words[=<regex>]
198           Equivalent to --word-diff=color plus (if a regex was specified)
199           --word-diff-regex=<regex>.
200
201       --no-renames
202           Turn off rename detection, even when the configuration file gives
203           the default to do so.
204
205       --check
206           Warn if changes introduce trailing whitespace or an indent that
207           uses a space before a tab. Exits with non-zero status if problems
208           are found. Not compatible with --exit-code.
209
210       --full-index
211           Instead of the first handful of characters, show the full pre- and
212           post-image blob object names on the "index" line when generating
213           patch format output.
214
215       --binary
216           In addition to --full-index, output a binary diff that can be
217           applied with git-apply.
218
219       --abbrev[=<n>]
220           Instead of showing the full 40-byte hexadecimal object name in
221           diff-raw format output and diff-tree header lines, show only a
222           partial prefix. This is independent of the --full-index option
223           above, which controls the diff-patch output format. Non default
224           number of digits can be specified with --abbrev=<n>.
225
226       -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
227           Break complete rewrite changes into pairs of delete and create.
228           This serves two purposes:
229
230           It affects the way a change that amounts to a total rewrite of a
231           file not as a series of deletion and insertion mixed together with
232           a very few lines that happen to match textually as the context, but
233           as a single deletion of everything old followed by a single
234           insertion of everything new, and the number m controls this aspect
235           of the -B option (defaults to 60%).  -B/70% specifies that less
236           than 30% of the original should remain in the result for git to
237           consider it a total rewrite (i.e. otherwise the resulting patch
238           will be a series of deletion and insertion mixed together with
239           context lines).
240
241           When used with -M, a totally-rewritten file is also considered as
242           the source of a rename (usually -M only considers a file that
243           disappeared as the source of a rename), and the number n controls
244           this aspect of the -B option (defaults to 50%).  -B20% specifies
245           that a change with addition and deletion compared to 20% or more of
246           the file’s size are eligible for being picked up as a possible
247           source of a rename to another file.
248
249       -M[<n>], --find-renames[=<n>]
250           Detect renames. If n is specified, it is a is a threshold on the
251           similarity index (i.e. amount of addition/deletions compared to the
252           file’s size). For example, -M90% means git should consider a
253           delete/add pair to be a rename if more than 90% of the file hasn’t
254           changed.
255
256       -C[<n>], --find-copies[=<n>]
257           Detect copies as well as renames. See also --find-copies-harder. If
258           n is specified, it has the same meaning as for -M<n>.
259
260       --find-copies-harder
261           For performance reasons, by default, -C option finds copies only if
262           the original file of the copy was modified in the same changeset.
263           This flag makes the command inspect unmodified files as candidates
264           for the source of copy. This is a very expensive operation for
265           large projects, so use it with caution. Giving more than one -C
266           option has the same effect.
267
268       -l<num>
269           The -M and -C options require O(n^2) processing time where n is the
270           number of potential rename/copy targets. This option prevents
271           rename/copy detection from running if the number of rename/copy
272           targets exceeds the specified number.
273
274       --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
275           Select only files that are Added (A), Copied (C), Deleted (D),
276           Modified (M), Renamed (R), have their type (i.e. regular file,
277           symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
278           (X), or have had their pairing Broken (B). Any combination of the
279           filter characters (including none) can be used. When *
280           (All-or-none) is added to the combination, all paths are selected
281           if there is any file that matches other criteria in the comparison;
282           if there is no file that matches other criteria, nothing is
283           selected.
284
285       -S<string>
286           Look for differences that introduce or remove an instance of
287           <string>. Note that this is different than the string simply
288           appearing in diff output; see the pickaxe entry in gitdiffcore(7)
289           for more details.
290
291       -G<regex>
292           Look for differences whose added or removed line matches the given
293           <regex>.
294
295       --pickaxe-all
296           When -S or -G finds a change, show all the changes in that
297           changeset, not just the files that contain the change in <string>.
298
299       --pickaxe-regex
300           Make the <string> not a plain string but an extended POSIX regex to
301           match.
302
303       -O<orderfile>
304           Output the patch in the order specified in the <orderfile>, which
305           has one shell glob pattern per line.
306
307       -R
308           Swap two inputs; that is, show differences from index or on-disk
309           file to tree contents.
310
311       --relative[=<path>]
312           When run from a subdirectory of the project, it can be told to
313           exclude changes outside the directory and show pathnames relative
314           to it with this option. When you are not in a subdirectory (e.g. in
315           a bare repository), you can name which subdirectory to make the
316           output relative to by giving a <path> as an argument.
317
318       -a, --text
319           Treat all files as text.
320
321       --ignore-space-at-eol
322           Ignore changes in whitespace at EOL.
323
324       -b, --ignore-space-change
325           Ignore changes in amount of whitespace. This ignores whitespace at
326           line end, and considers all other sequences of one or more
327           whitespace characters to be equivalent.
328
329       -w, --ignore-all-space
330           Ignore whitespace when comparing lines. This ignores differences
331           even if one line has whitespace where the other line has none.
332
333       --inter-hunk-context=<lines>
334           Show the context between diff hunks, up to the specified number of
335           lines, thereby fusing hunks that are close to each other.
336
337       --exit-code
338           Make the program exit with codes similar to diff(1). That is, it
339           exits with 1 if there were differences and 0 means no differences.
340
341       --quiet
342           Disable all output of the program. Implies --exit-code.
343
344       --ext-diff
345           Allow an external diff helper to be executed. If you set an
346           external diff driver with gitattributes(5), you need to use this
347           option with git-log(1) and friends.
348
349       --no-ext-diff
350           Disallow external diff drivers.
351
352       --ignore-submodules[=<when>]
353           Ignore changes to submodules in the diff generation. <when> can be
354           either "none", "untracked", "dirty" or "all", which is the default
355           Using "none" will consider the submodule modified when it either
356           contains untracked or modified files or its HEAD differs from the
357           commit recorded in the superproject and can be used to override any
358           settings of the ignore option in git-config(1) or gitmodules(5).
359           When "untracked" is used submodules are not considered dirty when
360           they only contain untracked content (but they are still scanned for
361           modified content). Using "dirty" ignores all changes to the work
362           tree of submodules, only changes to the commits stored in the
363           superproject are shown (this was the behavior until 1.7.0). Using
364           "all" hides all changes to submodules.
365
366       --src-prefix=<prefix>
367           Show the given source prefix instead of "a/".
368
369       --dst-prefix=<prefix>
370           Show the given destination prefix instead of "b/".
371
372       --no-prefix
373           Do not show any source or destination prefix.
374
375       For more detailed explanation on these common options, see also
376       gitdiffcore(7).
377
378       <path>...
379           The <paths> parameters, when given, are used to limit the diff to
380           the named paths (you can give directory names and get diff for all
381           files under them).
382

RAW OUTPUT FORMAT

384       The raw output format from "git-diff-index", "git-diff-tree",
385       "git-diff-files" and "git diff --raw" are very similar.
386
387       These commands all compare two sets of things; what is compared
388       differs:
389
390       git-diff-index <tree-ish>
391           compares the <tree-ish> and the files on the filesystem.
392
393       git-diff-index --cached <tree-ish>
394           compares the <tree-ish> and the index.
395
396       git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]
397           compares the trees named by the two arguments.
398
399       git-diff-files [<pattern>...]
400           compares the index and the files on the filesystem.
401
402       The "git-diff-tree" command begins its output by printing the hash of
403       what is being compared. After that, all the commands print one output
404       line per changed file.
405
406       An output line is formatted this way:
407
408           in-place edit  :100644 100644 bcd1234... 0123456... M file0
409           copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2
410           rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3
411           create         :000000 100644 0000000... 1234567... A file4
412           delete         :100644 000000 1234567... 0000000... D file5
413           unmerged       :000000 000000 0000000... 0000000... U file6
414
415
416       That is, from the left to the right:
417
418        1. a colon.
419
420        2. mode for "src"; 000000 if creation or unmerged.
421
422        3. a space.
423
424        4. mode for "dst"; 000000 if deletion or unmerged.
425
426        5. a space.
427
428        6. sha1 for "src"; 0{40} if creation or unmerged.
429
430        7. a space.
431
432        8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
433
434        9. a space.
435
436       10. status, followed by optional "score" number.
437
438       11. a tab or a NUL when -z option is used.
439
440       12. path for "src"
441
442       13. a tab or a NUL when -z option is used; only exists for C or R.
443
444       14. path for "dst"; only exists for C or R.
445
446       15. an LF or a NUL when -z option is used, to terminate the record.
447
448       Possible status letters are:
449
450       ·   A: addition of a file
451
452       ·   C: copy of a file into a new one
453
454       ·   D: deletion of a file
455
456       ·   M: modification of the contents or mode of a file
457
458       ·   R: renaming of a file
459
460       ·   T: change in the type of the file
461
462       ·   U: file is unmerged (you must complete the merge before it can be
463           committed)
464
465       ·   X: "unknown" change type (most probably a bug, please report it)
466
467       Status letters C and R are always followed by a score (denoting the
468       percentage of similarity between the source and target of the move or
469       copy), and are the only ones to be so.
470
471       <sha1> is shown as all 0’s if a file is new on the filesystem and it is
472       out of sync with the index.
473
474       Example:
475
476           :100644 100644 5be4a4...... 000000...... M file.c
477
478
479       When -z option is not used, TAB, LF, and backslash characters in
480       pathnames are represented as \t, \n, and \\, respectively.
481

DIFF FORMAT FOR MERGES

483       "git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or
484       --cc option to generate diff output also for merge commits. The output
485       differs from the format described above in the following way:
486
487        1. there is a colon for each parent
488
489        2. there are more "src" modes and "src" sha1
490
491        3. status is concatenated status characters for each parent
492
493        4. no optional "score" number
494
495        5. single path, only for "dst"
496
497       Example:
498
499           ::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM      describe.c
500
501
502       Note that combined diff lists only files which were modified from all
503       parents.
504

GENERATING PATCHES WITH -P

506       When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
507       with a -p option, "git diff" without the --raw option, or "git log"
508       with the "-p" option, they do not produce the output described above;
509       instead they produce a patch file. You can customize the creation of
510       such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
511       environment variables.
512
513       What the -p option produces is slightly different from the traditional
514       diff format:
515
516        1. It is preceded with a "git diff" header that looks like this:
517
518               diff --git a/file1 b/file2
519
520           The a/ and b/ filenames are the same unless rename/copy is
521           involved. Especially, even for a creation or a deletion, /dev/null
522           is not used in place of the a/ or b/ filenames.
523
524           When rename/copy is involved, file1 and file2 show the name of the
525           source file of the rename/copy and the name of the file that
526           rename/copy produces, respectively.
527
528        2. It is followed by one or more extended header lines:
529
530               old mode <mode>
531               new mode <mode>
532               deleted file mode <mode>
533               new file mode <mode>
534               copy from <path>
535               copy to <path>
536               rename from <path>
537               rename to <path>
538               similarity index <number>
539               dissimilarity index <number>
540               index <hash>..<hash> <mode>
541
542           File modes are printed as 6-digit octal numbers including the file
543           type and file permission bits.
544
545           Path names in extended headers do not include the a/ and b/
546           prefixes.
547
548           The similarity index is the percentage of unchanged lines, and the
549           dissimilarity index is the percentage of changed lines. It is a
550           rounded down integer, followed by a percent sign. The similarity
551           index value of 100% is thus reserved for two equal files, while
552           100% dissimilarity means that no line from the old file made it
553           into the new one.
554
555           The index line includes the SHA-1 checksum before and after the
556           change. The <mode> is included if the file mode does not change;
557           otherwise, separate lines indicate the old and the new mode.
558
559        3. TAB, LF, double quote and backslash characters in pathnames are
560           represented as \t, \n, \" and \\, respectively. If there is need
561           for such substitution then the whole pathname is put in double
562           quotes.
563
564        4. All the file1 files in the output refer to files before the commit,
565           and all the file2 files refer to files after the commit. It is
566           incorrect to apply each change to each file sequentially. For
567           example, this patch will swap a and b:
568
569               diff --git a/a b/b
570               rename from a
571               rename to b
572               diff --git a/b b/a
573               rename from b
574               rename to a
575

COMBINED DIFF FORMAT

577       Any diff-generating command can take the ‘-c` or --cc option to produce
578       a combined diff when showing a merge. This is the default format when
579       showing merges with git-diff(1) or git-show(1). Note also that you can
580       give the `-m’ option to any of these commands to force generation of
581       diffs with individual parents of a merge.
582
583       A combined diff format looks like this:
584
585           diff --combined describe.c
586           index fabadb8,cc95eb0..4866510
587           --- a/describe.c
588           +++ b/describe.c
589           @@@ -98,20 -98,12 +98,20 @@@
590                   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
591             }
592
593           - static void describe(char *arg)
594            -static void describe(struct commit *cmit, int last_one)
595           ++static void describe(char *arg, int last_one)
596             {
597            +      unsigned char sha1[20];
598            +      struct commit *cmit;
599                   struct commit_list *list;
600                   static int initialized = 0;
601                   struct commit_name *n;
602
603            +      if (get_sha1(arg, sha1) < 0)
604            +              usage(describe_usage);
605            +      cmit = lookup_commit_reference(sha1);
606            +      if (!cmit)
607            +              usage(describe_usage);
608            +
609                   if (!initialized) {
610                           initialized = 1;
611                           for_each_ref(get_name);
612
613
614
615        1. It is preceded with a "git diff" header, that looks like this (when
616           -c option is used):
617
618               diff --combined file
619
620           or like this (when --cc option is used):
621
622               diff --cc file
623
624        2. It is followed by one or more extended header lines (this example
625           shows a merge with two parents):
626
627               index <hash>,<hash>..<hash>
628               mode <mode>,<mode>..<mode>
629               new file mode <mode>
630               deleted file mode <mode>,<mode>
631
632           The mode <mode>,<mode>..<mode> line appears only if at least one of
633           the <mode> is different from the rest. Extended headers with
634           information about detected contents movement (renames and copying
635           detection) are designed to work with diff of two <tree-ish> and are
636           not used by combined diff format.
637
638        3. It is followed by two-line from-file/to-file header
639
640               --- a/file
641               +++ b/file
642
643           Similar to two-line header for traditional unified diff format,
644           /dev/null is used to signal created or deleted files.
645
646        4. Chunk header format is modified to prevent people from accidentally
647           feeding it to patch -p1. Combined diff format was created for
648           review of merge commit changes, and was not meant for apply. The
649           change is similar to the change in the extended index header:
650
651               @@@ <from-file-range> <from-file-range> <to-file-range> @@@
652
653           There are (number of parents + 1) @ characters in the chunk header
654           for combined diff format.
655
656       Unlike the traditional unified diff format, which shows two files A and
657       B with a single column that has - (minus — appears in A but removed in
658       B), + (plus — missing in A but added to B), or " " (space — unchanged)
659       prefix, this format compares two or more files file1, file2,... with
660       one file X, and shows how X differs from each of fileN. One column for
661       each of fileN is prepended to the output line to note how X’s line is
662       different from it.
663
664       A - character in the column N means that the line appears in fileN but
665       it does not appear in the result. A + character in the column N means
666       that the line appears in the result, and fileN does not have that line
667       (in other words, the line was added, from the point of view of that
668       parent).
669
670       In the above example output, the function signature was changed from
671       both files (hence two - removals from both file1 and file2, plus ++ to
672       mean one line that was added does not appear in either file1 nor
673       file2). Also eight other lines are the same from file1 but do not
674       appear in file2 (hence prefixed with +).
675
676       When shown by git diff-tree -c, it compares the parents of a merge
677       commit with the merge result (i.e. file1..fileN are the parents). When
678       shown by git diff-files -c, it compares the two unresolved merge
679       parents with the working tree file (i.e. file1 is stage 2 aka "our
680       version", file2 is stage 3 aka "their version").
681

OTHER DIFF FORMATS

683       The --summary option describes newly added, deleted, renamed and copied
684       files. The --stat option adds diffstat(1) graph to the output. These
685       options can be combined with other options, such as -p, and are meant
686       for human consumption.
687
688       When showing a change that involves a rename or a copy, --stat output
689       formats the pathnames compactly by combining common prefix and suffix
690       of the pathnames. For example, a change that moves arch/i386/Makefile
691       to arch/x86/Makefile while modifying 4 lines will be shown like this:
692
693           arch/{i386 => x86}/Makefile    |   4 +--
694
695
696       The --numstat option gives the diffstat(1) information but is designed
697       for easier machine consumption. An entry in --numstat output looks like
698       this:
699
700           1       2       README
701           3       1       arch/{i386 => x86}/Makefile
702
703
704       That is, from left to right:
705
706        1. the number of added lines;
707
708        2. a tab;
709
710        3. the number of deleted lines;
711
712        4. a tab;
713
714        5. pathname (possibly with rename/copy information);
715
716        6. a newline.
717
718       When -z output option is in effect, the output is formatted this way:
719
720           1       2       README NUL
721           3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
722
723
724       That is:
725
726        1. the number of added lines;
727
728        2. a tab;
729
730        3. the number of deleted lines;
731
732        4. a tab;
733
734        5. a NUL (only exists if renamed/copied);
735
736        6. pathname in preimage;
737
738        7. a NUL (only exists if renamed/copied);
739
740        8. pathname in postimage (only exists if renamed/copied);
741
742        9. a NUL.
743
744       The extra NUL before the preimage path in renamed case is to allow
745       scripts that read the output to tell if the current record being read
746       is a single-path record or a rename/copy record without reading ahead.
747       After reading added and deleted lines, reading up to NUL would yield
748       the pathname, but if that is NUL, the record will show two paths.
749

EXAMPLES

751       Various ways to check your working tree
752
753               $ git diff            (1)
754               $ git diff --cached   (2)
755               $ git diff HEAD       (3)
756
757           1. Changes in the working tree not yet staged for the next commit.
758           2. Changes between the index and your last commit; what you would
759           be committing if you run "git commit" without "-a" option.
760           3. Changes in the working tree since your last commit; what you
761           would be committing if you run "git commit -a"
762
763       Comparing with arbitrary commits
764
765               $ git diff test            (1)
766               $ git diff HEAD -- ./test  (2)
767               $ git diff HEAD^ HEAD      (3)
768
769           1. Instead of using the tip of the current branch, compare with the
770           tip of "test" branch.
771           2. Instead of comparing with the tip of "test" branch, compare with
772           the tip of the current branch, but limit the comparison to the file
773           "test".
774           3. Compare the version before the last commit and the last commit.
775
776       Comparing branches
777
778               $ git diff topic master    (1)
779               $ git diff topic..master   (2)
780               $ git diff topic...master  (3)
781
782           1. Changes between the tips of the topic and the master branches.
783           2. Same as above.
784           3. Changes that occurred on the master branch since when the topic
785           branch was started off it.
786
787       Limiting the diff output
788
789               $ git diff --diff-filter=MRC            (1)
790               $ git diff --name-status                (2)
791               $ git diff arch/i386 include/asm-i386   (3)
792
793           1. Show only modification, rename and copy, but not addition nor
794           deletion.
795           2. Show only names and the nature of change, but not actual diff
796           output.
797           3. Limit diff output to named subtrees.
798
799       Munging the diff output
800
801               $ git diff --find-copies-harder -B -C  (1)
802               $ git diff -R                          (2)
803
804           1. Spend extra cycles to find renames, copies and complete rewrites
805           (very expensive).
806           2. Output diff in reverse.
807

SEE ALSO

809       diff(1), git-difftool(1), git-log(1), gitdiffcore(7), git-format-
810       patch(1), git-apply(1)
811

AUTHOR

813       Written by Linus Torvalds <torvalds@osdl.org[1]>
814

DOCUMENTATION

816       Documentation by Junio C Hamano and the git-list
817       <git@vger.kernel.org[2]>.
818

GIT

820       Part of the git(1) suite
821

NOTES

823        1. torvalds@osdl.org
824           mailto:torvalds@osdl.org
825
826        2. git@vger.kernel.org
827           mailto:git@vger.kernel.org
828
829
830
831Git 1.7.4.4                       04/11/2011                       GIT-DIFF(1)
Impressum