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