1GIT-SHOW(1) Git Manual GIT-SHOW(1)
2
3
4
6 git-show - Show various types of objects
7
9 git show [<options>] [<object>...]
10
12 Shows one or more objects (blobs, trees, tags and commits).
13
14 For commits it shows the log message and textual diff. It also presents
15 the merge commit in a special format as produced by git diff-tree --cc.
16
17 For tags, it shows the tag message and the referenced objects.
18
19 For trees, it shows the names (equivalent to git ls-tree with
20 --name-only).
21
22 For plain blobs, it shows the plain contents.
23
24 Some options that git log command understands can be used to control
25 how the changes the commit introduces are shown.
26
27 This manual page describes only the most frequently used options.
28
30 <object>...
31 The names of objects to show (defaults to HEAD). For a more
32 complete list of ways to spell object names, see "SPECIFYING
33 REVISIONS" section in gitrevisions(7).
34
35 --pretty[=<format>], --format=<format>
36 Pretty-print the contents of the commit logs in a given format,
37 where <format> can be one of oneline, short, medium, full, fuller,
38 reference, email, raw, format:<string> and tformat:<string>. When
39 <format> is none of the above, and has %placeholder in it, it acts
40 as if --pretty=tformat:<format> were given.
41
42 See the "PRETTY FORMATS" section for some additional details for
43 each format. When =<format> part is omitted, it defaults to medium.
44
45 Note: you can specify the default pretty format in the repository
46 configuration (see git-config(1)).
47
48 --abbrev-commit
49 Instead of showing the full 40-byte hexadecimal commit object name,
50 show a prefix that names the object uniquely. "--abbrev=<n>" (which
51 also modifies diff output, if it is displayed) option can be used
52 to specify the minimum length of the prefix.
53
54 This should make "--pretty=oneline" a whole lot more readable for
55 people using 80-column terminals.
56
57 --no-abbrev-commit
58 Show the full 40-byte hexadecimal commit object name. This negates
59 --abbrev-commit, either explicit or implied by other options such
60 as "--oneline". It also overrides the log.abbrevCommit variable.
61
62 --oneline
63 This is a shorthand for "--pretty=oneline --abbrev-commit" used
64 together.
65
66 --encoding=<encoding>
67 Commit objects record the character encoding used for the log
68 message in their encoding header; this option can be used to tell
69 the command to re-code the commit log message in the encoding
70 preferred by the user. For non plumbing commands this defaults to
71 UTF-8. Note that if an object claims to be encoded in X and we are
72 outputting in X, we will output the object verbatim; this means
73 that invalid sequences in the original commit may be copied to the
74 output. Likewise, if iconv(3) fails to convert the commit, we will
75 quietly output the original object verbatim.
76
77 --expand-tabs=<n>, --expand-tabs, --no-expand-tabs
78 Perform a tab expansion (replace each tab with enough spaces to
79 fill to the next display column that is a multiple of <n>) in the
80 log message before showing it in the output. --expand-tabs is a
81 short-hand for --expand-tabs=8, and --no-expand-tabs is a
82 short-hand for --expand-tabs=0, which disables tab expansion.
83
84 By default, tabs are expanded in pretty formats that indent the log
85 message by 4 spaces (i.e. medium, which is the default, full, and
86 fuller).
87
88 --notes[=<ref>]
89 Show the notes (see git-notes(1)) that annotate the commit, when
90 showing the commit log message. This is the default for git log,
91 git show and git whatchanged commands when there is no --pretty,
92 --format, or --oneline option given on the command line.
93
94 By default, the notes shown are from the notes refs listed in the
95 core.notesRef and notes.displayRef variables (or corresponding
96 environment overrides). See git-config(1) for more details.
97
98 With an optional <ref> argument, use the ref to find the notes to
99 display. The ref can specify the full refname when it begins with
100 refs/notes/; when it begins with notes/, refs/ and otherwise
101 refs/notes/ is prefixed to form the full name of the ref.
102
103 Multiple --notes options can be combined to control which notes are
104 being displayed. Examples: "--notes=foo" will show only notes from
105 "refs/notes/foo"; "--notes=foo --notes" will show both notes from
106 "refs/notes/foo" and from the default notes ref(s).
107
108 --no-notes
109 Do not show notes. This negates the above --notes option, by
110 resetting the list of notes refs from which notes are shown.
111 Options are parsed in the order given on the command line, so e.g.
112 "--notes --notes=foo --no-notes --notes=bar" will only show notes
113 from "refs/notes/bar".
114
115 --show-notes-by-default
116 Show the default notes unless options for displaying specific notes
117 are given.
118
119 --show-notes[=<ref>], --[no-]standard-notes
120 These options are deprecated. Use the above --notes/--no-notes
121 options instead.
122
123 --show-signature
124 Check the validity of a signed commit object by passing the
125 signature to gpg --verify and show the output.
126
128 If the commit is a merge, and if the pretty-format is not oneline,
129 email or raw, an additional line is inserted before the Author: line.
130 This line begins with "Merge: " and the hashes of ancestral commits are
131 printed, separated by spaces. Note that the listed commits may not
132 necessarily be the list of the direct parent commits if you have
133 limited your view of history: for example, if you are only interested
134 in changes related to a certain directory or file.
135
136 There are several built-in formats, and you can define additional
137 formats by setting a pretty.<name> config option to either another
138 format name, or a format: string, as described below (see git-
139 config(1)). Here are the details of the built-in formats:
140
141 • oneline
142
143 <hash> <title-line>
144
145 This is designed to be as compact as possible.
146
147 • short
148
149 commit <hash>
150 Author: <author>
151
152 <title-line>
153
154 • medium
155
156 commit <hash>
157 Author: <author>
158 Date: <author-date>
159
160 <title-line>
161
162 <full-commit-message>
163
164 • full
165
166 commit <hash>
167 Author: <author>
168 Commit: <committer>
169
170 <title-line>
171
172 <full-commit-message>
173
174 • fuller
175
176 commit <hash>
177 Author: <author>
178 AuthorDate: <author-date>
179 Commit: <committer>
180 CommitDate: <committer-date>
181
182 <title-line>
183
184 <full-commit-message>
185
186 • reference
187
188 <abbrev-hash> (<title-line>, <short-author-date>)
189
190 This format is used to refer to another commit in a commit message
191 and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By
192 default, the date is formatted with --date=short unless another
193 --date option is explicitly specified. As with any format: with
194 format placeholders, its output is not affected by other options
195 like --decorate and --walk-reflogs.
196
197 • email
198
199 From <hash> <date>
200 From: <author>
201 Date: <author-date>
202 Subject: [PATCH] <title-line>
203
204 <full-commit-message>
205
206 • mboxrd
207
208 Like email, but lines in the commit message starting with "From "
209 (preceded by zero or more ">") are quoted with ">" so they aren’t
210 confused as starting a new commit.
211
212 • raw
213
214 The raw format shows the entire commit exactly as stored in the
215 commit object. Notably, the hashes are displayed in full,
216 regardless of whether --abbrev or --no-abbrev are used, and parents
217 information show the true parent commits, without taking grafts or
218 history simplification into account. Note that this format affects
219 the way commits are displayed, but not the way the diff is shown
220 e.g. with git log --raw. To get full object names in a raw diff
221 format, use --no-abbrev.
222
223 • format:<format-string>
224
225 The format:<format-string> format allows you to specify which
226 information you want to show. It works a little bit like printf
227 format, with the notable exception that you get a newline with %n
228 instead of \n.
229
230 E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
231 would show something like this:
232
233 The author of fe6e0ee was Junio C Hamano, 23 hours ago
234 The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
235
236 The placeholders are:
237
238 • Placeholders that expand to a single literal character:
239
240 %n
241 newline
242
243 %%
244 a raw %
245
246 %x00
247 %x followed by two hexadecimal digits is replaced with a
248 byte with the hexadecimal digits' value (we will call this
249 "literal formatting code" in the rest of this document).
250
251 • Placeholders that affect formatting of later placeholders:
252
253 %Cred
254 switch color to red
255
256 %Cgreen
257 switch color to green
258
259 %Cblue
260 switch color to blue
261
262 %Creset
263 reset color
264
265 %C(...)
266 color specification, as described under Values in the
267 "CONFIGURATION FILE" section of git-config(1). By default,
268 colors are shown only when enabled for log output (by
269 color.diff, color.ui, or --color, and respecting the auto
270 settings of the former if we are going to a terminal).
271 %C(auto,...) is accepted as a historical synonym for the
272 default (e.g., %C(auto,red)). Specifying %C(always,...)
273 will show the colors even when color is not otherwise
274 enabled (though consider just using --color=always to
275 enable color for the whole output, including this format
276 and anything else git might color). auto alone (i.e.
277 %C(auto)) will turn on auto coloring on the next
278 placeholders until the color is switched again.
279
280 %m
281 left (<), right (>) or boundary (-) mark
282
283 %w([<w>[,<i1>[,<i2>]]])
284 switch line wrapping, like the -w option of git-
285 shortlog(1).
286
287 %<( <N> [,trunc|ltrunc|mtrunc])
288 make the next placeholder take at least N column widths,
289 padding spaces on the right if necessary. Optionally
290 truncate (with ellipsis ..) at the left (ltrunc) ..ft, the
291 middle (mtrunc) mi..le, or the end (trunc) rig.., if the
292 output is longer than N columns. Note 1: that truncating
293 only works correctly with N >= 2. Note 2: spaces around the
294 N and M (see below) values are optional. Note 3: Emojis and
295 other wide characters will take two display columns, which
296 may over-run column boundaries. Note 4: decomposed
297 character combining marks may be misplaced at padding
298 boundaries.
299
300 %<|( <M> )
301 make the next placeholder take at least until Mth display
302 column, padding spaces on the right if necessary. Use
303 negative M values for column positions measured from the
304 right hand edge of the terminal window.
305
306 %>( <N> ), %>|( <M> )
307 similar to %<( <N> ), %<|( <M> ) respectively, but padding
308 spaces on the left
309
310 %>>( <N> ), %>>|( <M> )
311 similar to %>( <N> ), %>|( <M> ) respectively, except that
312 if the next placeholder takes more spaces than given and
313 there are spaces on its left, use those spaces
314
315 %><( <N> ), %><|( <M> )
316 similar to %<( <N> ), %<|( <M> ) respectively, but padding
317 both sides (i.e. the text is centered)
318
319 • Placeholders that expand to information extracted from the
320 commit:
321
322 %H
323 commit hash
324
325 %h
326 abbreviated commit hash
327
328 %T
329 tree hash
330
331 %t
332 abbreviated tree hash
333
334 %P
335 parent hashes
336
337 %p
338 abbreviated parent hashes
339
340 %an
341 author name
342
343 %aN
344 author name (respecting .mailmap, see git-shortlog(1) or
345 git-blame(1))
346
347 %ae
348 author email
349
350 %aE
351 author email (respecting .mailmap, see git-shortlog(1) or
352 git-blame(1))
353
354 %al
355 author email local-part (the part before the @ sign)
356
357 %aL
358 author local-part (see %al) respecting .mailmap, see git-
359 shortlog(1) or git-blame(1))
360
361 %ad
362 author date (format respects --date= option)
363
364 %aD
365 author date, RFC2822 style
366
367 %ar
368 author date, relative
369
370 %at
371 author date, UNIX timestamp
372
373 %ai
374 author date, ISO 8601-like format
375
376 %aI
377 author date, strict ISO 8601 format
378
379 %as
380 author date, short format (YYYY-MM-DD)
381
382 %ah
383 author date, human style (like the --date=human option of
384 git-rev-list(1))
385
386 %cn
387 committer name
388
389 %cN
390 committer name (respecting .mailmap, see git-shortlog(1) or
391 git-blame(1))
392
393 %ce
394 committer email
395
396 %cE
397 committer email (respecting .mailmap, see git-shortlog(1)
398 or git-blame(1))
399
400 %cl
401 committer email local-part (the part before the @ sign)
402
403 %cL
404 committer local-part (see %cl) respecting .mailmap, see
405 git-shortlog(1) or git-blame(1))
406
407 %cd
408 committer date (format respects --date= option)
409
410 %cD
411 committer date, RFC2822 style
412
413 %cr
414 committer date, relative
415
416 %ct
417 committer date, UNIX timestamp
418
419 %ci
420 committer date, ISO 8601-like format
421
422 %cI
423 committer date, strict ISO 8601 format
424
425 %cs
426 committer date, short format (YYYY-MM-DD)
427
428 %ch
429 committer date, human style (like the --date=human option
430 of git-rev-list(1))
431
432 %d
433 ref names, like the --decorate option of git-log(1)
434
435 %D
436 ref names without the " (", ")" wrapping.
437
438 %(decorate[:<options>])
439 ref names with custom decorations. The decorate string may
440 be followed by a colon and zero or more comma-separated
441 options. Option values may contain literal formatting
442 codes. These must be used for commas (%x2C) and closing
443 parentheses (%x29), due to their role in the option syntax.
444
445 • prefix=<value>: Shown before the list of ref names.
446 Defaults to " (".
447
448 • suffix=<value>: Shown after the list of ref names.
449 Defaults to ")".
450
451 • separator=<value>: Shown between ref names. Defaults to
452 ", ".
453
454 • pointer=<value>: Shown between HEAD and the branch it
455 points to, if any. Defaults to " -> ".
456
457 • tag=<value>: Shown before tag names. Defaults to
458 "tag: ".
459
460 For example, to produce decorations with no wrapping or tag
461 annotations, and spaces as separators:
462
463 + %(decorate:prefix=,suffix=,tag=,separator= )
464
465 %(describe[:<options>])
466 human-readable name, like git-describe(1); empty string for
467 undescribable commits. The describe string may be followed by a
468 colon and zero or more comma-separated options. Descriptions
469 can be inconsistent when tags are added or removed at the same
470 time.
471
472 • tags[=<bool-value>]: Instead of only considering annotated
473 tags, consider lightweight tags as well.
474
475 • abbrev=<number>: Instead of using the default number of
476 hexadecimal digits (which will vary according to the number
477 of objects in the repository with a default of 7) of the
478 abbreviated object name, use <number> digits, or as many
479 digits as needed to form a unique object name.
480
481 • match=<pattern>: Only consider tags matching the given
482 glob(7) pattern, excluding the "refs/tags/" prefix.
483
484 • exclude=<pattern>: Do not consider tags matching the given
485 glob(7) pattern, excluding the "refs/tags/" prefix.
486
487 %S
488 ref name given on the command line by which the commit was
489 reached (like git log --source), only works with git log
490
491 %e
492 encoding
493
494 %s
495 subject
496
497 %f
498 sanitized subject line, suitable for a filename
499
500 %b
501 body
502
503 %B
504 raw body (unwrapped subject and body)
505
506 %N
507 commit notes
508
509 %GG
510 raw verification message from GPG for a signed commit
511
512 %G?
513 show "G" for a good (valid) signature, "B" for a bad signature,
514 "U" for a good signature with unknown validity, "X" for a good
515 signature that has expired, "Y" for a good signature made by an
516 expired key, "R" for a good signature made by a revoked key,
517 "E" if the signature cannot be checked (e.g. missing key) and
518 "N" for no signature
519
520 %GS
521 show the name of the signer for a signed commit
522
523 %GK
524 show the key used to sign a signed commit
525
526 %GF
527 show the fingerprint of the key used to sign a signed commit
528
529 %GP
530 show the fingerprint of the primary key whose subkey was used
531 to sign a signed commit
532
533 %GT
534 show the trust level for the key used to sign a signed commit
535
536 %gD
537 reflog selector, e.g., refs/stash@{1} or refs/stash@{2 minutes
538 ago}; the format follows the rules described for the -g option.
539 The portion before the @ is the refname as given on the command
540 line (so git log -g refs/heads/master would yield
541 refs/heads/master@{0}).
542
543 %gd
544 shortened reflog selector; same as %gD, but the refname portion
545 is shortened for human readability (so refs/heads/master
546 becomes just master).
547
548 %gn
549 reflog identity name
550
551 %gN
552 reflog identity name (respecting .mailmap, see git-shortlog(1)
553 or git-blame(1))
554
555 %ge
556 reflog identity email
557
558 %gE
559 reflog identity email (respecting .mailmap, see git-shortlog(1)
560 or git-blame(1))
561
562 %gs
563 reflog subject
564
565 %(trailers[:<options>])
566 display the trailers of the body as interpreted by git-
567 interpret-trailers(1). The trailers string may be followed by a
568 colon and zero or more comma-separated options. If any option
569 is provided multiple times, the last occurrence wins.
570
571 • key=<key>: only show trailers with specified <key>.
572 Matching is done case-insensitively and trailing colon is
573 optional. If option is given multiple times trailer lines
574 matching any of the keys are shown. This option
575 automatically enables the only option so that non-trailer
576 lines in the trailer block are hidden. If that is not
577 desired it can be disabled with only=false. E.g.,
578 %(trailers:key=Reviewed-by) shows trailer lines with key
579 Reviewed-by.
580
581 • only[=<bool>]: select whether non-trailer lines from the
582 trailer block should be included.
583
584 • separator=<sep>: specify a separator inserted between
585 trailer lines. When this option is not given each trailer
586 line is terminated with a line feed character. The string
587 <sep> may contain the literal formatting codes described
588 above. To use comma as separator one must use %x2C as it
589 would otherwise be parsed as next option. E.g.,
590 %(trailers:key=Ticket,separator=%x2C ) shows all trailer
591 lines whose key is "Ticket" separated by a comma and a
592 space.
593
594 • unfold[=<bool>]: make it behave as if interpret-trailer’s
595 --unfold option was given. E.g.,
596 %(trailers:only,unfold=true) unfolds and shows all trailer
597 lines.
598
599 • keyonly[=<bool>]: only show the key part of the trailer.
600
601 • valueonly[=<bool>]: only show the value part of the
602 trailer.
603
604 • key_value_separator=<sep>: specify a separator inserted
605 between trailer lines. When this option is not given each
606 trailer key-value pair is separated by ": ". Otherwise it
607 shares the same semantics as separator=<sep> above.
608
609 Note
610 Some placeholders may depend on other options given to the revision
611 traversal engine. For example, the %g* reflog options will insert
612 an empty string unless we are traversing reflog entries (e.g., by
613 git log -g). The %d and %D placeholders will use the "short"
614 decoration format if --decorate was not already provided on the
615 command line.
616
617 The boolean options accept an optional value [=<bool-value>]. The
618 values true, false, on, off etc. are all accepted. See the "boolean"
619 sub-section in "EXAMPLES" in git-config(1). If a boolean option is
620 given with no value, it’s enabled.
621
622 If you add a + (plus sign) after % of a placeholder, a line-feed is
623 inserted immediately before the expansion if and only if the
624 placeholder expands to a non-empty string.
625
626 If you add a - (minus sign) after % of a placeholder, all consecutive
627 line-feeds immediately preceding the expansion are deleted if and only
628 if the placeholder expands to an empty string.
629
630 If you add a ` ` (space) after % of a placeholder, a space is inserted
631 immediately before the expansion if and only if the placeholder expands
632 to a non-empty string.
633
634 • tformat:
635
636 The tformat: format works exactly like format:, except that it
637 provides "terminator" semantics instead of "separator" semantics.
638 In other words, each commit has the message terminator character
639 (usually a newline) appended, rather than a separator placed
640 between entries. This means that the final entry of a single-line
641 format will be properly terminated with a new line, just as the
642 "oneline" format does. For example:
643
644 $ git log -2 --pretty=format:%h 4da45bef \
645 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
646 4da45be
647 7134973 -- NO NEWLINE
648
649 $ git log -2 --pretty=tformat:%h 4da45bef \
650 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
651 4da45be
652 7134973
653
654 In addition, any unrecognized string that has a % in it is
655 interpreted as if it has tformat: in front of it. For example,
656 these two are equivalent:
657
658 $ git log -2 --pretty=tformat:%h 4da45bef
659 $ git log -2 --pretty=%h 4da45bef
660
662 The options below can be used to change the way git show generates diff
663 output.
664
665 -p, -u, --patch
666 Generate patch (see the section called “GENERATING PATCH TEXT WITH
667 -P”).
668
669 -s, --no-patch
670 Suppress all output from the diff machinery. Useful for commands
671 like git show that show the patch by default to squelch their
672 output, or to cancel the effect of options like --patch, --stat
673 earlier on the command line in an alias.
674
675 -m
676 Show diffs for merge commits in the default format. This is similar
677 to --diff-merges=on, except -m will produce no output unless -p is
678 given as well.
679
680 -c
681 Produce combined diff output for merge commits. Shortcut for
682 --diff-merges=combined -p.
683
684 --cc
685 Produce dense combined diff output for merge commits. Shortcut for
686 --diff-merges=dense-combined -p.
687
688 --dd
689 Produce diff with respect to first parent for both merge and
690 regular commits. Shortcut for --diff-merges=first-parent -p.
691
692 --remerge-diff
693 Produce remerge-diff output for merge commits. Shortcut for
694 --diff-merges=remerge -p.
695
696 --no-diff-merges
697 Synonym for --diff-merges=off.
698
699 --diff-merges=<format>
700 Specify diff format to be used for merge commits. Default is
701 `dense-combined` unless --first-parent is in use, in which case
702 first-parent is the default.
703
704 The following formats are supported:
705
706 off, none
707 Disable output of diffs for merge commits. Useful to override
708 implied value.
709
710 on, m
711 Make diff output for merge commits to be shown in the default
712 format. The default format can be changed using log.diffMerges
713 configuration variable, whose default value is separate.
714
715 first-parent, 1
716 Show full diff with respect to first parent. This is the same
717 format as --patch produces for non-merge commits.
718
719 separate
720 Show full diff with respect to each of parents. Separate log
721 entry and diff is generated for each parent.
722
723 combined, c
724 Show differences from each of the parents to the merge result
725 simultaneously instead of showing pairwise diff between a
726 parent and the result one at a time. Furthermore, it lists only
727 files which were modified from all parents.
728
729 dense-combined, cc
730 Further compress output produced by --diff-merges=combined by
731 omitting uninteresting hunks whose contents in the parents have
732 only two variants and the merge result picks one of them
733 without modification.
734
735 remerge, r
736 Remerge two-parent merge commits to create a temporary tree
737 object—potentially containing files with conflict markers and
738 such. A diff is then shown between that temporary tree and the
739 actual merge commit.
740
741 The output emitted when this option is used is subject to
742 change, and so is its interaction with other options (unless
743 explicitly documented).
744
745 --combined-all-paths
746 This flag causes combined diffs (used for merge commits) to list
747 the name of the file from all parents. It thus only has effect when
748 --diff-merges=[dense-]combined is in use, and is likely only useful
749 if filename changes are detected (i.e. when either rename or copy
750 detection have been requested).
751
752 -U<n>, --unified=<n>
753 Generate diffs with <n> lines of context instead of the usual
754 three. Implies --patch.
755
756 --output=<file>
757 Output to a specific file instead of stdout.
758
759 --output-indicator-new=<char>, --output-indicator-old=<char>,
760 --output-indicator-context=<char>
761 Specify the character used to indicate new, old or context lines in
762 the generated patch. Normally they are +, - and ' ' respectively.
763
764 --raw
765 For each commit, show a summary of changes using the raw diff
766 format. See the "RAW OUTPUT FORMAT" section of git-diff(1). This is
767 different from showing the log itself in raw format, which you can
768 achieve with --format=raw.
769
770 --patch-with-raw
771 Synonym for -p --raw.
772
773 -t
774 Show the tree objects in the diff output.
775
776 --indent-heuristic
777 Enable the heuristic that shifts diff hunk boundaries to make
778 patches easier to read. This is the default.
779
780 --no-indent-heuristic
781 Disable the indent heuristic.
782
783 --minimal
784 Spend extra time to make sure the smallest possible diff is
785 produced.
786
787 --patience
788 Generate a diff using the "patience diff" algorithm.
789
790 --histogram
791 Generate a diff using the "histogram diff" algorithm.
792
793 --anchored=<text>
794 Generate a diff using the "anchored diff" algorithm.
795
796 This option may be specified more than once.
797
798 If a line exists in both the source and destination, exists only
799 once, and starts with this text, this algorithm attempts to prevent
800 it from appearing as a deletion or addition in the output. It uses
801 the "patience diff" algorithm internally.
802
803 --diff-algorithm={patience|minimal|histogram|myers}
804 Choose a diff algorithm. The variants are as follows:
805
806 default, myers
807 The basic greedy diff algorithm. Currently, this is the
808 default.
809
810 minimal
811 Spend extra time to make sure the smallest possible diff is
812 produced.
813
814 patience
815 Use "patience diff" algorithm when generating patches.
816
817 histogram
818 This algorithm extends the patience algorithm to "support
819 low-occurrence common elements".
820
821 For instance, if you configured the diff.algorithm variable to a
822 non-default value and want to use the default one, then you have to
823 use --diff-algorithm=default option.
824
825 --stat[=<width>[,<name-width>[,<count>]]]
826 Generate a diffstat. By default, as much space as necessary will be
827 used for the filename part, and the rest for the graph part.
828 Maximum width defaults to terminal width, or 80 columns if not
829 connected to a terminal, and can be overridden by <width>. The
830 width of the filename part can be limited by giving another width
831 <name-width> after a comma or by setting
832 diff.statNameWidth=<width>. The width of the graph part can be
833 limited by using --stat-graph-width=<width> or by setting
834 diff.statGraphWidth=<width>. Using --stat or --stat-graph-width
835 affects all commands generating a stat graph, while setting
836 diff.statNameWidth or diff.statGraphWidth does not affect git
837 format-patch. By giving a third parameter <count>, you can limit
838 the output to the first <count> lines, followed by ... if there
839 are more.
840
841 These parameters can also be set individually with
842 --stat-width=<width>, --stat-name-width=<name-width> and
843 --stat-count=<count>.
844
845 --compact-summary
846 Output a condensed summary of extended header information such as
847 file creations or deletions ("new" or "gone", optionally "+l" if
848 it’s a symlink) and mode changes ("+x" or "-x" for adding or
849 removing executable bit respectively) in diffstat. The information
850 is put between the filename part and the graph part. Implies
851 --stat.
852
853 --numstat
854 Similar to --stat, but shows number of added and deleted lines in
855 decimal notation and pathname without abbreviation, to make it more
856 machine friendly. For binary files, outputs two - instead of saying
857 0 0.
858
859 --shortstat
860 Output only the last line of the --stat format containing total
861 number of modified files, as well as number of added and deleted
862 lines.
863
864 -X[<param1,param2,...>], --dirstat[=<param1,param2,...>]
865 Output the distribution of relative amount of changes for each
866 sub-directory. The behavior of --dirstat can be customized by
867 passing it a comma separated list of parameters. The defaults are
868 controlled by the diff.dirstat configuration variable (see git-
869 config(1)). The following parameters are available:
870
871 changes
872 Compute the dirstat numbers by counting the lines that have
873 been removed from the source, or added to the destination. This
874 ignores the amount of pure code movements within a file. In
875 other words, rearranging lines in a file is not counted as much
876 as other changes. This is the default behavior when no
877 parameter is given.
878
879 lines
880 Compute the dirstat numbers by doing the regular line-based
881 diff analysis, and summing the removed/added line counts. (For
882 binary files, count 64-byte chunks instead, since binary files
883 have no natural concept of lines). This is a more expensive
884 --dirstat behavior than the changes behavior, but it does count
885 rearranged lines within a file as much as other changes. The
886 resulting output is consistent with what you get from the other
887 --*stat options.
888
889 files
890 Compute the dirstat numbers by counting the number of files
891 changed. Each changed file counts equally in the dirstat
892 analysis. This is the computationally cheapest --dirstat
893 behavior, since it does not have to look at the file contents
894 at all.
895
896 cumulative
897 Count changes in a child directory for the parent directory as
898 well. Note that when using cumulative, the sum of the
899 percentages reported may exceed 100%. The default
900 (non-cumulative) behavior can be specified with the
901 noncumulative parameter.
902
903 <limit>
904 An integer parameter specifies a cut-off percent (3% by
905 default). Directories contributing less than this percentage of
906 the changes are not shown in the output.
907
908 Example: The following will count changed files, while ignoring
909 directories with less than 10% of the total amount of changed
910 files, and accumulating child directory counts in the parent
911 directories: --dirstat=files,10,cumulative.
912
913 --cumulative
914 Synonym for --dirstat=cumulative
915
916 --dirstat-by-file[=<param1,param2>...]
917 Synonym for --dirstat=files,param1,param2...
918
919 --summary
920 Output a condensed summary of extended header information such as
921 creations, renames and mode changes.
922
923 --patch-with-stat
924 Synonym for -p --stat.
925
926 -z
927 Separate the commits with NULs instead of newlines.
928
929 Also, when --raw or --numstat has been given, do not munge
930 pathnames and use NULs as output field terminators.
931
932 Without this option, pathnames with "unusual" characters are quoted
933 as explained for the configuration variable core.quotePath (see
934 git-config(1)).
935
936 --name-only
937 Show only names of changed files. The file names are often encoded
938 in UTF-8. For more information see the discussion about encoding in
939 the git-log(1) manual page.
940
941 --name-status
942 Show only names and status of changed files. See the description of
943 the --diff-filter option on what the status letters mean. Just like
944 --name-only the file names are often encoded in UTF-8.
945
946 --submodule[=<format>]
947 Specify how differences in submodules are shown. When specifying
948 --submodule=short the short format is used. This format just shows
949 the names of the commits at the beginning and end of the range.
950 When --submodule or --submodule=log is specified, the log format is
951 used. This format lists the commits in the range like git-
952 submodule(1) summary does. When --submodule=diff is specified, the
953 diff format is used. This format shows an inline diff of the
954 changes in the submodule contents between the commit range.
955 Defaults to diff.submodule or the short format if the config option
956 is unset.
957
958 --color[=<when>]
959 Show colored diff. --color (i.e. without =<when>) is the same as
960 --color=always. <when> can be one of always, never, or auto.
961
962 --no-color
963 Turn off colored diff. It is the same as --color=never.
964
965 --color-moved[=<mode>]
966 Moved lines of code are colored differently. The <mode> defaults to
967 no if the option is not given and to zebra if the option with no
968 mode is given. The mode must be one of:
969
970 no
971 Moved lines are not highlighted.
972
973 default
974 Is a synonym for zebra. This may change to a more sensible mode
975 in the future.
976
977 plain
978 Any line that is added in one location and was removed in
979 another location will be colored with color.diff.newMoved.
980 Similarly color.diff.oldMoved will be used for removed lines
981 that are added somewhere else in the diff. This mode picks up
982 any moved line, but it is not very useful in a review to
983 determine if a block of code was moved without permutation.
984
985 blocks
986 Blocks of moved text of at least 20 alphanumeric characters are
987 detected greedily. The detected blocks are painted using either
988 the color.diff.{old,new}Moved color. Adjacent blocks cannot be
989 told apart.
990
991 zebra
992 Blocks of moved text are detected as in blocks mode. The blocks
993 are painted using either the color.diff.{old,new}Moved color or
994 color.diff.{old,new}MovedAlternative. The change between the
995 two colors indicates that a new block was detected.
996
997 dimmed-zebra
998 Similar to zebra, but additional dimming of uninteresting parts
999 of moved code is performed. The bordering lines of two adjacent
1000 blocks are considered interesting, the rest is uninteresting.
1001 dimmed_zebra is a deprecated synonym.
1002
1003 --no-color-moved
1004 Turn off move detection. This can be used to override configuration
1005 settings. It is the same as --color-moved=no.
1006
1007 --color-moved-ws=<modes>
1008 This configures how whitespace is ignored when performing the move
1009 detection for --color-moved. These modes can be given as a comma
1010 separated list:
1011
1012 no
1013 Do not ignore whitespace when performing move detection.
1014
1015 ignore-space-at-eol
1016 Ignore changes in whitespace at EOL.
1017
1018 ignore-space-change
1019 Ignore changes in amount of whitespace. This ignores whitespace
1020 at line end, and considers all other sequences of one or more
1021 whitespace characters to be equivalent.
1022
1023 ignore-all-space
1024 Ignore whitespace when comparing lines. This ignores
1025 differences even if one line has whitespace where the other
1026 line has none.
1027
1028 allow-indentation-change
1029 Initially ignore any whitespace in the move detection, then
1030 group the moved code blocks only into a block if the change in
1031 whitespace is the same per line. This is incompatible with the
1032 other modes.
1033
1034 --no-color-moved-ws
1035 Do not ignore whitespace when performing move detection. This can
1036 be used to override configuration settings. It is the same as
1037 --color-moved-ws=no.
1038
1039 --word-diff[=<mode>]
1040 Show a word diff, using the <mode> to delimit changed words. By
1041 default, words are delimited by whitespace; see --word-diff-regex
1042 below. The <mode> defaults to plain, and must be one of:
1043
1044 color
1045 Highlight changed words using only colors. Implies --color.
1046
1047 plain
1048 Show words as [-removed-] and {+added+}. Makes no attempts to
1049 escape the delimiters if they appear in the input, so the
1050 output may be ambiguous.
1051
1052 porcelain
1053 Use a special line-based format intended for script
1054 consumption. Added/removed/unchanged runs are printed in the
1055 usual unified diff format, starting with a +/-/` ` character at
1056 the beginning of the line and extending to the end of the line.
1057 Newlines in the input are represented by a tilde ~ on a line of
1058 its own.
1059
1060 none
1061 Disable word diff again.
1062
1063 Note that despite the name of the first mode, color is used to
1064 highlight the changed parts in all modes if enabled.
1065
1066 --word-diff-regex=<regex>
1067 Use <regex> to decide what a word is, instead of considering runs
1068 of non-whitespace to be a word. Also implies --word-diff unless it
1069 was already enabled.
1070
1071 Every non-overlapping match of the <regex> is considered a word.
1072 Anything between these matches is considered whitespace and
1073 ignored(!) for the purposes of finding differences. You may want to
1074 append |[^[:space:]] to your regular expression to make sure that
1075 it matches all non-whitespace characters. A match that contains a
1076 newline is silently truncated(!) at the newline.
1077
1078 For example, --word-diff-regex=. will treat each character as a
1079 word and, correspondingly, show differences character by character.
1080
1081 The regex can also be set via a diff driver or configuration
1082 option, see gitattributes(5) or git-config(1). Giving it explicitly
1083 overrides any diff driver or configuration setting. Diff drivers
1084 override configuration settings.
1085
1086 --color-words[=<regex>]
1087 Equivalent to --word-diff=color plus (if a regex was specified)
1088 --word-diff-regex=<regex>.
1089
1090 --no-renames
1091 Turn off rename detection, even when the configuration file gives
1092 the default to do so.
1093
1094 --[no-]rename-empty
1095 Whether to use empty blobs as rename source.
1096
1097 --check
1098 Warn if changes introduce conflict markers or whitespace errors.
1099 What are considered whitespace errors is controlled by
1100 core.whitespace configuration. By default, trailing whitespaces
1101 (including lines that consist solely of whitespaces) and a space
1102 character that is immediately followed by a tab character inside
1103 the initial indent of the line are considered whitespace errors.
1104 Exits with non-zero status if problems are found. Not compatible
1105 with --exit-code.
1106
1107 --ws-error-highlight=<kind>
1108 Highlight whitespace errors in the context, old or new lines of the
1109 diff. Multiple values are separated by comma, none resets previous
1110 values, default reset the list to new and all is a shorthand for
1111 old,new,context. When this option is not given, and the
1112 configuration variable diff.wsErrorHighlight is not set, only
1113 whitespace errors in new lines are highlighted. The whitespace
1114 errors are colored with color.diff.whitespace.
1115
1116 --full-index
1117 Instead of the first handful of characters, show the full pre- and
1118 post-image blob object names on the "index" line when generating
1119 patch format output.
1120
1121 --binary
1122 In addition to --full-index, output a binary diff that can be
1123 applied with git-apply. Implies --patch.
1124
1125 --abbrev[=<n>]
1126 Instead of showing the full 40-byte hexadecimal object name in
1127 diff-raw format output and diff-tree header lines, show the
1128 shortest prefix that is at least <n> hexdigits long that uniquely
1129 refers the object. In diff-patch output format, --full-index takes
1130 higher precedence, i.e. if --full-index is specified, full blob
1131 names will be shown regardless of --abbrev. Non default number of
1132 digits can be specified with --abbrev=<n>.
1133
1134 -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
1135 Break complete rewrite changes into pairs of delete and create.
1136 This serves two purposes:
1137
1138 It affects the way a change that amounts to a total rewrite of a
1139 file not as a series of deletion and insertion mixed together with
1140 a very few lines that happen to match textually as the context, but
1141 as a single deletion of everything old followed by a single
1142 insertion of everything new, and the number m controls this aspect
1143 of the -B option (defaults to 60%). -B/70% specifies that less
1144 than 30% of the original should remain in the result for Git to
1145 consider it a total rewrite (i.e. otherwise the resulting patch
1146 will be a series of deletion and insertion mixed together with
1147 context lines).
1148
1149 When used with -M, a totally-rewritten file is also considered as
1150 the source of a rename (usually -M only considers a file that
1151 disappeared as the source of a rename), and the number n controls
1152 this aspect of the -B option (defaults to 50%). -B20% specifies
1153 that a change with addition and deletion compared to 20% or more of
1154 the file’s size are eligible for being picked up as a possible
1155 source of a rename to another file.
1156
1157 -M[<n>], --find-renames[=<n>]
1158 If generating diffs, detect and report renames for each commit. For
1159 following files across renames while traversing history, see
1160 --follow. If n is specified, it is a threshold on the similarity
1161 index (i.e. amount of addition/deletions compared to the file’s
1162 size). For example, -M90% means Git should consider a delete/add
1163 pair to be a rename if more than 90% of the file hasn’t changed.
1164 Without a % sign, the number is to be read as a fraction, with a
1165 decimal point before it. I.e., -M5 becomes 0.5, and is thus the
1166 same as -M50%. Similarly, -M05 is the same as -M5%. To limit
1167 detection to exact renames, use -M100%. The default similarity
1168 index is 50%.
1169
1170 -C[<n>], --find-copies[=<n>]
1171 Detect copies as well as renames. See also --find-copies-harder. If
1172 n is specified, it has the same meaning as for -M<n>.
1173
1174 --find-copies-harder
1175 For performance reasons, by default, -C option finds copies only if
1176 the original file of the copy was modified in the same changeset.
1177 This flag makes the command inspect unmodified files as candidates
1178 for the source of copy. This is a very expensive operation for
1179 large projects, so use it with caution. Giving more than one -C
1180 option has the same effect.
1181
1182 -D, --irreversible-delete
1183 Omit the preimage for deletes, i.e. print only the header but not
1184 the diff between the preimage and /dev/null. The resulting patch is
1185 not meant to be applied with patch or git apply; this is solely for
1186 people who want to just concentrate on reviewing the text after the
1187 change. In addition, the output obviously lacks enough information
1188 to apply such a patch in reverse, even manually, hence the name of
1189 the option.
1190
1191 When used together with -B, omit also the preimage in the deletion
1192 part of a delete/create pair.
1193
1194 -l<num>
1195 The -M and -C options involve some preliminary steps that can
1196 detect subsets of renames/copies cheaply, followed by an exhaustive
1197 fallback portion that compares all remaining unpaired destinations
1198 to all relevant sources. (For renames, only remaining unpaired
1199 sources are relevant; for copies, all original sources are
1200 relevant.) For N sources and destinations, this exhaustive check is
1201 O(N^2). This option prevents the exhaustive portion of rename/copy
1202 detection from running if the number of source/destination files
1203 involved exceeds the specified number. Defaults to
1204 diff.renameLimit. Note that a value of 0 is treated as unlimited.
1205
1206 --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
1207 Select only files that are Added (A), Copied (C), Deleted (D),
1208 Modified (M), Renamed (R), have their type (i.e. regular file,
1209 symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
1210 (X), or have had their pairing Broken (B). Any combination of the
1211 filter characters (including none) can be used. When *
1212 (All-or-none) is added to the combination, all paths are selected
1213 if there is any file that matches other criteria in the comparison;
1214 if there is no file that matches other criteria, nothing is
1215 selected.
1216
1217 Also, these upper-case letters can be downcased to exclude. E.g.
1218 --diff-filter=ad excludes added and deleted paths.
1219
1220 Note that not all diffs can feature all types. For instance, copied
1221 and renamed entries cannot appear if detection for those types is
1222 disabled.
1223
1224 -S<string>
1225 Look for differences that change the number of occurrences of the
1226 specified string (i.e. addition/deletion) in a file. Intended for
1227 the scripter’s use.
1228
1229 It is useful when you’re looking for an exact block of code (like a
1230 struct), and want to know the history of that block since it first
1231 came into being: use the feature iteratively to feed the
1232 interesting block in the preimage back into -S, and keep going
1233 until you get the very first version of the block.
1234
1235 Binary files are searched as well.
1236
1237 -G<regex>
1238 Look for differences whose patch text contains added/removed lines
1239 that match <regex>.
1240
1241 To illustrate the difference between -S<regex> --pickaxe-regex and
1242 -G<regex>, consider a commit with the following diff in the same
1243 file:
1244
1245 + return frotz(nitfol, two->ptr, 1, 0);
1246 ...
1247 - hit = frotz(nitfol, mf2.ptr, 1, 0);
1248
1249 While git log -G"frotz\(nitfol" will show this commit, git log
1250 -S"frotz\(nitfol" --pickaxe-regex will not (because the number of
1251 occurrences of that string did not change).
1252
1253 Unless --text is supplied patches of binary files without a
1254 textconv filter will be ignored.
1255
1256 See the pickaxe entry in gitdiffcore(7) for more information.
1257
1258 --find-object=<object-id>
1259 Look for differences that change the number of occurrences of the
1260 specified object. Similar to -S, just the argument is different in
1261 that it doesn’t search for a specific string but for a specific
1262 object id.
1263
1264 The object can be a blob or a submodule commit. It implies the -t
1265 option in git-log to also find trees.
1266
1267 --pickaxe-all
1268 When -S or -G finds a change, show all the changes in that
1269 changeset, not just the files that contain the change in <string>.
1270
1271 --pickaxe-regex
1272 Treat the <string> given to -S as an extended POSIX regular
1273 expression to match.
1274
1275 -O<orderfile>
1276 Control the order in which files appear in the output. This
1277 overrides the diff.orderFile configuration variable (see git-
1278 config(1)). To cancel diff.orderFile, use -O/dev/null.
1279
1280 The output order is determined by the order of glob patterns in
1281 <orderfile>. All files with pathnames that match the first pattern
1282 are output first, all files with pathnames that match the second
1283 pattern (but not the first) are output next, and so on. All files
1284 with pathnames that do not match any pattern are output last, as if
1285 there was an implicit match-all pattern at the end of the file. If
1286 multiple pathnames have the same rank (they match the same pattern
1287 but no earlier patterns), their output order relative to each other
1288 is the normal order.
1289
1290 <orderfile> is parsed as follows:
1291
1292 • Blank lines are ignored, so they can be used as separators for
1293 readability.
1294
1295 • Lines starting with a hash ("#") are ignored, so they can be
1296 used for comments. Add a backslash ("\") to the beginning of
1297 the pattern if it starts with a hash.
1298
1299 • Each other line contains a single pattern.
1300
1301 Patterns have the same syntax and semantics as patterns used for
1302 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
1303 matches a pattern if removing any number of the final pathname
1304 components matches the pattern. For example, the pattern "foo*bar"
1305 matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".
1306
1307 --skip-to=<file>, --rotate-to=<file>
1308 Discard the files before the named <file> from the output (i.e.
1309 skip to), or move them to the end of the output (i.e. rotate to).
1310 These options were invented primarily for the use of the git
1311 difftool command, and may not be very useful otherwise.
1312
1313 -R
1314 Swap two inputs; that is, show differences from index or on-disk
1315 file to tree contents.
1316
1317 --relative[=<path>], --no-relative
1318 When run from a subdirectory of the project, it can be told to
1319 exclude changes outside the directory and show pathnames relative
1320 to it with this option. When you are not in a subdirectory (e.g. in
1321 a bare repository), you can name which subdirectory to make the
1322 output relative to by giving a <path> as an argument.
1323 --no-relative can be used to countermand both diff.relative config
1324 option and previous --relative.
1325
1326 -a, --text
1327 Treat all files as text.
1328
1329 --ignore-cr-at-eol
1330 Ignore carriage-return at the end of line when doing a comparison.
1331
1332 --ignore-space-at-eol
1333 Ignore changes in whitespace at EOL.
1334
1335 -b, --ignore-space-change
1336 Ignore changes in amount of whitespace. This ignores whitespace at
1337 line end, and considers all other sequences of one or more
1338 whitespace characters to be equivalent.
1339
1340 -w, --ignore-all-space
1341 Ignore whitespace when comparing lines. This ignores differences
1342 even if one line has whitespace where the other line has none.
1343
1344 --ignore-blank-lines
1345 Ignore changes whose lines are all blank.
1346
1347 -I<regex>, --ignore-matching-lines=<regex>
1348 Ignore changes whose all lines match <regex>. This option may be
1349 specified more than once.
1350
1351 --inter-hunk-context=<lines>
1352 Show the context between diff hunks, up to the specified number of
1353 lines, thereby fusing hunks that are close to each other. Defaults
1354 to diff.interHunkContext or 0 if the config option is unset.
1355
1356 -W, --function-context
1357 Show whole function as context lines for each change. The function
1358 names are determined in the same way as git diff works out patch
1359 hunk headers (see Defining a custom hunk-header in
1360 gitattributes(5)).
1361
1362 --ext-diff
1363 Allow an external diff helper to be executed. If you set an
1364 external diff driver with gitattributes(5), you need to use this
1365 option with git-log(1) and friends.
1366
1367 --no-ext-diff
1368 Disallow external diff drivers.
1369
1370 --textconv, --no-textconv
1371 Allow (or disallow) external text conversion filters to be run when
1372 comparing binary files. See gitattributes(5) for details. Because
1373 textconv filters are typically a one-way conversion, the resulting
1374 diff is suitable for human consumption, but cannot be applied. For
1375 this reason, textconv filters are enabled by default only for git-
1376 diff(1) and git-log(1), but not for git-format-patch(1) or diff
1377 plumbing commands.
1378
1379 --ignore-submodules[=<when>]
1380 Ignore changes to submodules in the diff generation. <when> can be
1381 either "none", "untracked", "dirty" or "all", which is the default.
1382 Using "none" will consider the submodule modified when it either
1383 contains untracked or modified files or its HEAD differs from the
1384 commit recorded in the superproject and can be used to override any
1385 settings of the ignore option in git-config(1) or gitmodules(5).
1386 When "untracked" is used submodules are not considered dirty when
1387 they only contain untracked content (but they are still scanned for
1388 modified content). Using "dirty" ignores all changes to the work
1389 tree of submodules, only changes to the commits stored in the
1390 superproject are shown (this was the behavior until 1.7.0). Using
1391 "all" hides all changes to submodules.
1392
1393 --src-prefix=<prefix>
1394 Show the given source prefix instead of "a/".
1395
1396 --dst-prefix=<prefix>
1397 Show the given destination prefix instead of "b/".
1398
1399 --no-prefix
1400 Do not show any source or destination prefix.
1401
1402 --default-prefix
1403 Use the default source and destination prefixes ("a/" and "b/").
1404 This is usually the default already, but may be used to override
1405 config such as diff.noprefix.
1406
1407 --line-prefix=<prefix>
1408 Prepend an additional prefix to every line of output.
1409
1410 --ita-invisible-in-index
1411 By default entries added by "git add -N" appear as an existing
1412 empty file in "git diff" and a new file in "git diff --cached".
1413 This option makes the entry appear as a new file in "git diff" and
1414 non-existent in "git diff --cached". This option could be reverted
1415 with --ita-visible-in-index. Both options are experimental and
1416 could be removed in future.
1417
1418 For more detailed explanation on these common options, see also
1419 gitdiffcore(7).
1420
1422 Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
1423 diff-tree(1), or git-diff-files(1) with the -p option produces patch
1424 text. You can customize the creation of patch text via the
1425 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables (see
1426 git(1)), and the diff attribute (see gitattributes(5)).
1427
1428 What the -p option produces is slightly different from the traditional
1429 diff format:
1430
1431 1. It is preceded by a "git diff" header that looks like this:
1432
1433 diff --git a/file1 b/file2
1434
1435 The a/ and b/ filenames are the same unless rename/copy is
1436 involved. Especially, even for a creation or a deletion, /dev/null
1437 is not used in place of the a/ or b/ filenames.
1438
1439 When a rename/copy is involved, file1 and file2 show the name of
1440 the source file of the rename/copy and the name of the file that
1441 the rename/copy produces, respectively.
1442
1443 2. It is followed by one or more extended header lines:
1444
1445 old mode <mode>
1446 new mode <mode>
1447 deleted file mode <mode>
1448 new file mode <mode>
1449 copy from <path>
1450 copy to <path>
1451 rename from <path>
1452 rename to <path>
1453 similarity index <number>
1454 dissimilarity index <number>
1455 index <hash>..<hash> <mode>
1456
1457 File modes are printed as 6-digit octal numbers including the file
1458 type and file permission bits.
1459
1460 Path names in extended headers do not include the a/ and b/
1461 prefixes.
1462
1463 The similarity index is the percentage of unchanged lines, and the
1464 dissimilarity index is the percentage of changed lines. It is a
1465 rounded down integer, followed by a percent sign. The similarity
1466 index value of 100% is thus reserved for two equal files, while
1467 100% dissimilarity means that no line from the old file made it
1468 into the new one.
1469
1470 The index line includes the blob object names before and after the
1471 change. The <mode> is included if the file mode does not change;
1472 otherwise, separate lines indicate the old and the new mode.
1473
1474 3. Pathnames with "unusual" characters are quoted as explained for the
1475 configuration variable core.quotePath (see git-config(1)).
1476
1477 4. All the file1 files in the output refer to files before the commit,
1478 and all the file2 files refer to files after the commit. It is
1479 incorrect to apply each change to each file sequentially. For
1480 example, this patch will swap a and b:
1481
1482 diff --git a/a b/b
1483 rename from a
1484 rename to b
1485 diff --git a/b b/a
1486 rename from b
1487 rename to a
1488
1489 5. Hunk headers mention the name of the function to which the hunk
1490 applies. See "Defining a custom hunk-header" in gitattributes(5)
1491 for details of how to tailor this to specific languages.
1492
1494 Any diff-generating command can take the -c or --cc option to produce a
1495 combined diff when showing a merge. This is the default format when
1496 showing merges with git-diff(1) or git-show(1). Note also that you can
1497 give suitable --diff-merges option to any of these commands to force
1498 generation of diffs in a specific format.
1499
1500 A "combined diff" format looks like this:
1501
1502 diff --combined describe.c
1503 index fabadb8,cc95eb0..4866510
1504 --- a/describe.c
1505 +++ b/describe.c
1506 @@@ -98,20 -98,12 +98,20 @@@
1507 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1508 }
1509
1510 - static void describe(char *arg)
1511 -static void describe(struct commit *cmit, int last_one)
1512 ++static void describe(char *arg, int last_one)
1513 {
1514 + unsigned char sha1[20];
1515 + struct commit *cmit;
1516 struct commit_list *list;
1517 static int initialized = 0;
1518 struct commit_name *n;
1519
1520 + if (get_sha1(arg, sha1) < 0)
1521 + usage(describe_usage);
1522 + cmit = lookup_commit_reference(sha1);
1523 + if (!cmit)
1524 + usage(describe_usage);
1525 +
1526 if (!initialized) {
1527 initialized = 1;
1528 for_each_ref(get_name);
1529
1530 1. It is preceded by a "git diff" header, that looks like this (when
1531 the -c option is used):
1532
1533 diff --combined file
1534
1535 or like this (when the --cc option is used):
1536
1537 diff --cc file
1538
1539 2. It is followed by one or more extended header lines (this example
1540 shows a merge with two parents):
1541
1542 index <hash>,<hash>..<hash>
1543 mode <mode>,<mode>..<mode>
1544 new file mode <mode>
1545 deleted file mode <mode>,<mode>
1546
1547 The mode <mode>,<mode>..<mode> line appears only if at least one of
1548 the <mode> is different from the rest. Extended headers with
1549 information about detected content movement (renames and copying
1550 detection) are designed to work with the diff of two <tree-ish> and
1551 are not used by combined diff format.
1552
1553 3. It is followed by a two-line from-file/to-file header:
1554
1555 --- a/file
1556 +++ b/file
1557
1558 Similar to the two-line header for the traditional unified diff
1559 format, /dev/null is used to signal created or deleted files.
1560
1561 However, if the --combined-all-paths option is provided, instead of
1562 a two-line from-file/to-file, you get an N+1 line from-file/to-file
1563 header, where N is the number of parents in the merge commit:
1564
1565 --- a/file
1566 --- a/file
1567 --- a/file
1568 +++ b/file
1569
1570 This extended format can be useful if rename or copy detection is
1571 active, to allow you to see the original name of the file in
1572 different parents.
1573
1574 4. Chunk header format is modified to prevent people from accidentally
1575 feeding it to patch -p1. Combined diff format was created for
1576 review of merge commit changes, and was not meant to be applied.
1577 The change is similar to the change in the extended index header:
1578
1579 @@@ <from-file-range> <from-file-range> <to-file-range> @@@
1580
1581 There are (number of parents + 1) @ characters in the chunk header
1582 for combined diff format.
1583
1584 Unlike the traditional unified diff format, which shows two files A and
1585 B with a single column that has - (minus — appears in A but removed in
1586 B), + (plus — missing in A but added to B), or " " (space — unchanged)
1587 prefix, this format compares two or more files file1, file2,... with
1588 one file X, and shows how X differs from each of fileN. One column for
1589 each of fileN is prepended to the output line to note how X’s line is
1590 different from it.
1591
1592 A - character in the column N means that the line appears in fileN but
1593 it does not appear in the result. A + character in the column N means
1594 that the line appears in the result, and fileN does not have that line
1595 (in other words, the line was added, from the point of view of that
1596 parent).
1597
1598 In the above example output, the function signature was changed from
1599 both files (hence two - removals from both file1 and file2, plus ++ to
1600 mean one line that was added does not appear in either file1 or file2).
1601 Also, eight other lines are the same from file1 but do not appear in
1602 file2 (hence prefixed with +).
1603
1604 When shown by git diff-tree -c, it compares the parents of a merge
1605 commit with the merge result (i.e. file1..fileN are the parents). When
1606 shown by git diff-files -c, it compares the two unresolved merge
1607 parents with the working tree file (i.e. file1 is stage 2 aka "our
1608 version", file2 is stage 3 aka "their version").
1609
1611 git show v1.0.0
1612 Shows the tag v1.0.0, along with the object the tag points at.
1613
1614 git show v1.0.0^{tree}
1615 Shows the tree pointed to by the tag v1.0.0.
1616
1617 git show -s --format=%s v1.0.0^{commit}
1618 Shows the subject of the commit pointed to by the tag v1.0.0.
1619
1620 git show next~10:Documentation/README
1621 Shows the contents of the file Documentation/README as they were
1622 current in the 10th last commit of the branch next.
1623
1624 git show master:Makefile master:t/Makefile
1625 Concatenates the contents of said Makefiles in the head of the
1626 branch master.
1627
1629 Git is to some extent character encoding agnostic.
1630
1631 • The contents of the blob objects are uninterpreted sequences of
1632 bytes. There is no encoding translation at the core level.
1633
1634 • Path names are encoded in UTF-8 normalization form C. This applies
1635 to tree objects, the index file, ref names, as well as path names
1636 in command line arguments, environment variables and config files
1637 (.git/config (see git-config(1)), gitignore(5), gitattributes(5)
1638 and gitmodules(5)).
1639
1640 Note that Git at the core level treats path names simply as
1641 sequences of non-NUL bytes, there are no path name encoding
1642 conversions (except on Mac and Windows). Therefore, using non-ASCII
1643 path names will mostly work even on platforms and file systems that
1644 use legacy extended ASCII encodings. However, repositories created
1645 on such systems will not work properly on UTF-8-based systems (e.g.
1646 Linux, Mac, Windows) and vice versa. Additionally, many Git-based
1647 tools simply assume path names to be UTF-8 and will fail to display
1648 other encodings correctly.
1649
1650 • Commit log messages are typically encoded in UTF-8, but other
1651 extended ASCII encodings are also supported. This includes
1652 ISO-8859-x, CP125x and many others, but not UTF-16/32, EBCDIC and
1653 CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x, CP9xx etc.).
1654
1655 Although we encourage that the commit log messages are encoded in
1656 UTF-8, both the core and Git Porcelain are designed not to force UTF-8
1657 on projects. If all participants of a particular project find it more
1658 convenient to use legacy encodings, Git does not forbid it. However,
1659 there are a few things to keep in mind.
1660
1661 1. git commit and git commit-tree issue a warning if the commit log
1662 message given to it does not look like a valid UTF-8 string, unless
1663 you explicitly say your project uses a legacy encoding. The way to
1664 say this is to have i18n.commitEncoding in .git/config file, like
1665 this:
1666
1667 [i18n]
1668 commitEncoding = ISO-8859-1
1669
1670 Commit objects created with the above setting record the value of
1671 i18n.commitEncoding in their encoding header. This is to help other
1672 people who look at them later. Lack of this header implies that the
1673 commit log message is encoded in UTF-8.
1674
1675 2. git log, git show, git blame and friends look at the encoding
1676 header of a commit object, and try to re-code the log message into
1677 UTF-8 unless otherwise specified. You can specify the desired
1678 output encoding with i18n.logOutputEncoding in .git/config file,
1679 like this:
1680
1681 [i18n]
1682 logOutputEncoding = ISO-8859-1
1683
1684 If you do not have this configuration variable, the value of
1685 i18n.commitEncoding is used instead.
1686
1687 Note that we deliberately chose not to re-code the commit log message
1688 when a commit is made to force UTF-8 at the commit object level,
1689 because re-coding to UTF-8 is not necessarily a reversible operation.
1690
1692 Part of the git(1) suite
1693
1694
1695
1696Git 2.43.0 11/20/2023 GIT-SHOW(1)