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