1GIT-LOG(1) Git Manual GIT-LOG(1)
2
3
4
6 git-log - Show commit logs
7
9 git log [<options>] [<revision range>] [[--] <path>...]
10
11
13 Shows the commit logs.
14
15 The command takes options applicable to the git rev-list command to
16 control what is shown and how, and options applicable to the git diff-*
17 commands to control how the changes each commit introduces are shown.
18
20 --follow
21 Continue listing the history of a file beyond renames (works only
22 for a single file).
23
24 --no-decorate, --decorate[=short|full|no]
25 Print out the ref names of any commits that are shown. If short is
26 specified, the ref name prefixes refs/heads/, refs/tags/ and
27 refs/remotes/ will not be printed. If full is specified, the full
28 ref name (including prefix) will be printed. The default option is
29 short.
30
31 --source
32 Print out the ref name given on the command line by which each
33 commit was reached.
34
35 --use-mailmap
36 Use mailmap file to map author and committer names and email to
37 canonical real names and email addresses. See git-shortlog(1).
38
39 --full-diff
40 Without this flag, "git log -p <path>..." shows commits that touch
41 the specified paths, and diffs about the same specified paths. With
42 this, the full diff is shown for commits that touch the specified
43 paths; this means that "<path>..." limits only commits, and doesn’t
44 limit diff for those commits.
45
46 Note that this affects all diff-based output types, e.g. those
47 produced by --stat etc.
48
49 --log-size
50 Before the log message print out its size in bytes. Intended mainly
51 for porcelain tools consumption. If Git is unable to produce a
52 valid value size is set to zero. Note that only message is
53 considered, if also a diff is shown its size is not included.
54
55 <revision range>
56 Show only commits in the specified revision range. When no
57 <revision range> is specified, it defaults to HEAD (i.e. the whole
58 history leading to the current commit). origin..HEAD specifies all
59 the commits reachable from the current commit (i.e. HEAD), but not
60 from origin. For a complete list of ways to spell <revision range>,
61 see the "Specifying Ranges" section of gitrevisions(7).
62
63 [--] <path>...
64 Show only commits that are enough to explain how the files that
65 match the specified paths came to be. See "History Simplification"
66 below for details and other simplification modes.
67
68 Paths may need to be prefixed with "-- " to separate them from
69 options or the revision range, when confusion arises.
70
71 Commit Limiting
72 Besides specifying a range of commits that should be listed using the
73 special notations explained in the description, additional commit
74 limiting may be applied.
75
76 Using more options generally further limits the output (e.g.
77 --since=<date1> limits to commits newer than <date1>, and using it with
78 --grep=<pattern> further limits to commits whose log message has a line
79 that matches <pattern>), unless otherwise noted.
80
81 Note that these are applied before commit ordering and formatting
82 options, such as --reverse.
83
84 -<number>, -n <number>, --max-count=<number>
85 Limit the number of commits to output.
86
87 --skip=<number>
88 Skip number commits before starting to show the commit output.
89
90 --since=<date>, --after=<date>
91 Show commits more recent than a specific date.
92
93 --until=<date>, --before=<date>
94 Show commits older than a specific date.
95
96 --author=<pattern>, --committer=<pattern>
97 Limit the commits output to ones with author/committer header lines
98 that match the specified pattern (regular expression). With more
99 than one --author=<pattern>, commits whose author matches any of
100 the given patterns are chosen (similarly for multiple
101 --committer=<pattern>).
102
103 --grep-reflog=<pattern>
104 Limit the commits output to ones with reflog entries that match the
105 specified pattern (regular expression). With more than one
106 --grep-reflog, commits whose reflog message matches any of the
107 given patterns are chosen. It is an error to use this option unless
108 --walk-reflogs is in use.
109
110 --grep=<pattern>
111 Limit the commits output to ones with log message that matches the
112 specified pattern (regular expression). With more than one
113 --grep=<pattern>, commits whose message matches any of the given
114 patterns are chosen (but see --all-match).
115
116 When --show-notes is in effect, the message from the notes as if it
117 is part of the log message.
118
119 --all-match
120 Limit the commits output to ones that match all given --grep,
121 instead of ones that match at least one.
122
123 -i, --regexp-ignore-case
124 Match the regexp limiting patterns without regard to letters case.
125
126 --basic-regexp
127 Consider the limiting patterns to be basic regular expressions;
128 this is the default.
129
130 -E, --extended-regexp
131 Consider the limiting patterns to be extended regular expressions
132 instead of the default basic regular expressions.
133
134 -F, --fixed-strings
135 Consider the limiting patterns to be fixed strings (don’t interpret
136 pattern as a regular expression).
137
138 --perl-regexp
139 Consider the limiting patterns to be Perl-compatible regexp.
140 Requires libpcre to be compiled in.
141
142 --remove-empty
143 Stop when a given path disappears from the tree.
144
145 --merges
146 Print only merge commits. This is exactly the same as
147 --min-parents=2.
148
149 --no-merges
150 Do not print commits with more than one parent. This is exactly the
151 same as --max-parents=1.
152
153 --min-parents=<number>, --max-parents=<number>, --no-min-parents,
154 --no-max-parents
155 Show only commits which have at least (or at most) that many
156 commits. In particular, --max-parents=1 is the same as --no-merges,
157 --min-parents=2 is the same as --merges. --max-parents=0 gives all
158 root commits and --min-parents=3 all octopus merges.
159
160 --no-min-parents and --no-max-parents reset these limits (to no
161 limit) again. Equivalent forms are --min-parents=0 (any commit has
162 0 or more parents) and --max-parents=-1 (negative numbers denote no
163 upper limit).
164
165 --first-parent
166 Follow only the first parent commit upon seeing a merge commit.
167 This option can give a better overview when viewing the evolution
168 of a particular topic branch, because merges into a topic branch
169 tend to be only about adjusting to updated upstream from time to
170 time, and this option allows you to ignore the individual commits
171 brought in to your history by such a merge.
172
173 --not
174 Reverses the meaning of the ^ prefix (or lack thereof) for all
175 following revision specifiers, up to the next --not.
176
177 --all
178 Pretend as if all the refs in refs/ are listed on the command line
179 as <commit>.
180
181 --branches[=<pattern>]
182 Pretend as if all the refs in refs/heads are listed on the command
183 line as <commit>. If <pattern> is given, limit branches to ones
184 matching given shell glob. If pattern lacks ?, *, or [, /* at the
185 end is implied.
186
187 --tags[=<pattern>]
188 Pretend as if all the refs in refs/tags are listed on the command
189 line as <commit>. If <pattern> is given, limit tags to ones
190 matching given shell glob. If pattern lacks ?, *, or [, /* at the
191 end is implied.
192
193 --remotes[=<pattern>]
194 Pretend as if all the refs in refs/remotes are listed on the
195 command line as <commit>. If <pattern> is given, limit
196 remote-tracking branches to ones matching given shell glob. If
197 pattern lacks ?, *, or [, /* at the end is implied.
198
199 --glob=<glob-pattern>
200 Pretend as if all the refs matching shell glob <glob-pattern> are
201 listed on the command line as <commit>. Leading refs/, is
202 automatically prepended if missing. If pattern lacks ?, *, or [, /*
203 at the end is implied.
204
205 --ignore-missing
206 Upon seeing an invalid object name in the input, pretend as if the
207 bad input was not given.
208
209 --bisect
210 Pretend as if the bad bisection ref refs/bisect/bad was listed and
211 as if it was followed by --not and the good bisection refs
212 refs/bisect/good-* on the command line.
213
214 --stdin
215 In addition to the <commit> listed on the command line, read them
216 from the standard input. If a -- separator is seen, stop reading
217 commits and start reading paths to limit the result.
218
219 --cherry-mark
220 Like --cherry-pick (see below) but mark equivalent commits with =
221 rather than omitting them, and inequivalent ones with +.
222
223 --cherry-pick
224 Omit any commit that introduces the same change as another commit
225 on the "other side" when the set of commits are limited with
226 symmetric difference.
227
228 For example, if you have two branches, A and B, a usual way to list
229 all commits on only one side of them is with --left-right (see the
230 example below in the description of the --left-right option). It
231 however shows the commits that were cherry-picked from the other
232 branch (for example, "3rd on b" may be cherry-picked from branch
233 A). With this option, such pairs of commits are excluded from the
234 output.
235
236 --left-only, --right-only
237 List only commits on the respective side of a symmetric range, i.e.
238 only those which would be marked < resp. > by --left-right.
239
240 For example, --cherry-pick --right-only A...B omits those commits
241 from B which are in A or are patch-equivalent to a commit in A. In
242 other words, this lists the + commits from git cherry A B. More
243 precisely, --cherry-pick --right-only --no-merges gives the exact
244 list.
245
246 --cherry
247 A synonym for --right-only --cherry-mark --no-merges; useful to
248 limit the output to the commits on our side and mark those that
249 have been applied to the other side of a forked history with git
250 log --cherry upstream...mybranch, similar to git cherry upstream
251 mybranch.
252
253 -g, --walk-reflogs
254 Instead of walking the commit ancestry chain, walk reflog entries
255 from the most recent one to older ones. When this option is used
256 you cannot specify commits to exclude (that is, ^commit,
257 commit1..commit2, nor commit1...commit2 notations cannot be used).
258
259 With --pretty format other than oneline (for obvious reasons), this
260 causes the output to have two extra lines of information taken from
261 the reflog. By default, commit@{Nth} notation is used in the
262 output. When the starting commit is specified as commit@{now},
263 output also uses commit@{timestamp} notation instead. Under
264 --pretty=oneline, the commit message is prefixed with this
265 information on the same line. This option cannot be combined with
266 --reverse. See also git-reflog(1).
267
268 --merge
269 After a failed merge, show refs that touch files having a conflict
270 and don’t exist on all heads to merge.
271
272 --boundary
273 Output uninteresting commits at the boundary, which are usually not
274 shown.
275
276 History Simplification
277 Sometimes you are only interested in parts of the history, for example
278 the commits modifying a particular <path>. But there are two parts of
279 History Simplification, one part is selecting the commits and the other
280 is how to do it, as there are various strategies to simplify the
281 history.
282
283 The following options select the commits to be shown:
284
285 <paths>
286 Commits modifying the given <paths> are selected.
287
288 --simplify-by-decoration
289 Commits that are referred by some branch or tag are selected.
290
291 Note that extra commits can be shown to give a meaningful history.
292
293 The following options affect the way the simplification is performed:
294
295 Default mode
296 Simplifies the history to the simplest history explaining the final
297 state of the tree. Simplest because it prunes some side branches if
298 the end result is the same (i.e. merging branches with the same
299 content)
300
301 --full-history
302 Same as the default mode, but does not prune some history.
303
304 --dense
305 Only the selected commits are shown, plus some to have a meaningful
306 history.
307
308 --sparse
309 All commits in the simplified history are shown.
310
311 --simplify-merges
312 Additional option to --full-history to remove some needless merges
313 from the resulting history, as there are no selected commits
314 contributing to this merge.
315
316 --ancestry-path
317 When given a range of commits to display (e.g. commit1..commit2 or
318 commit2 ^commit1), only display commits that exist directly on the
319 ancestry chain between the commit1 and commit2, i.e. commits that
320 are both descendants of commit1, and ancestors of commit2.
321
322 A more detailed explanation follows.
323
324 Suppose you specified foo as the <paths>. We shall call commits that
325 modify foo !TREESAME, and the rest TREESAME. (In a diff filtered for
326 foo, they look different and equal, respectively.)
327
328 In the following, we will always refer to the same example history to
329 illustrate the differences between simplification settings. We assume
330 that you are filtering for a file foo in this commit graph:
331
332 .-A---M---N---O---P
333 / / / / /
334 I B C D E
335 \ / / / /
336 `-------------'
337
338
339 The horizontal line of history A---P is taken to be the first parent of
340 each merge. The commits are:
341
342 · I is the initial commit, in which foo exists with contents "asdf",
343 and a file quux exists with contents "quux". Initial commits are
344 compared to an empty tree, so I is !TREESAME.
345
346 · In A, foo contains just "foo".
347
348 · B contains the same change as A. Its merge M is trivial and hence
349 TREESAME to all parents.
350
351 · C does not change foo, but its merge N changes it to "foobar", so
352 it is not TREESAME to any parent.
353
354 · D sets foo to "baz". Its merge O combines the strings from N and D
355 to "foobarbaz"; i.e., it is not TREESAME to any parent.
356
357 · E changes quux to "xyzzy", and its merge P combines the strings to
358 "quux xyzzy". Despite appearing interesting, P is TREESAME to all
359 parents.
360
361 rev-list walks backwards through history, including or excluding
362 commits based on whether --full-history and/or parent rewriting (via
363 --parents or --children) are used. The following settings are
364 available.
365
366 Default mode
367 Commits are included if they are not TREESAME to any parent (though
368 this can be changed, see --sparse below). If the commit was a
369 merge, and it was TREESAME to one parent, follow only that parent.
370 (Even if there are several TREESAME parents, follow only one of
371 them.) Otherwise, follow all parents.
372
373 This results in:
374
375 .-A---N---O
376 / / /
377 I---------D
378
379 Note how the rule to only follow the TREESAME parent, if one is
380 available, removed B from consideration entirely. C was considered
381 via N, but is TREESAME. Root commits are compared to an empty tree,
382 so I is !TREESAME.
383
384 Parent/child relations are only visible with --parents, but that
385 does not affect the commits selected in default mode, so we have
386 shown the parent lines.
387
388 --full-history without parent rewriting
389 This mode differs from the default in one point: always follow all
390 parents of a merge, even if it is TREESAME to one of them. Even if
391 more than one side of the merge has commits that are included, this
392 does not imply that the merge itself is! In the example, we get
393
394 I A B N D O
395
396 P and M were excluded because they are TREESAME to a parent. E, C
397 and B were all walked, but only B was !TREESAME, so the others do
398 not appear.
399
400 Note that without parent rewriting, it is not really possible to
401 talk about the parent/child relationships between the commits, so
402 we show them disconnected.
403
404 --full-history with parent rewriting
405 Ordinary commits are only included if they are !TREESAME (though
406 this can be changed, see --sparse below).
407
408 Merges are always included. However, their parent list is
409 rewritten: Along each parent, prune away commits that are not
410 included themselves. This results in
411
412 .-A---M---N---O---P
413 / / / / /
414 I B / D /
415 \ / / / /
416 `-------------'
417
418 Compare to --full-history without rewriting above. Note that E was
419 pruned away because it is TREESAME, but the parent list of P was
420 rewritten to contain E's parent I. The same happened for C and N.
421 Note also that P was included despite being TREESAME.
422
423 In addition to the above settings, you can change whether TREESAME
424 affects inclusion:
425
426 --dense
427 Commits that are walked are included if they are not TREESAME to
428 any parent.
429
430 --sparse
431 All commits that are walked are included.
432
433 Note that without --full-history, this still simplifies merges: if
434 one of the parents is TREESAME, we follow only that one, so the
435 other sides of the merge are never walked.
436
437 --simplify-merges
438 First, build a history graph in the same way that --full-history
439 with parent rewriting does (see above).
440
441 Then simplify each commit C to its replacement C' in the final
442 history according to the following rules:
443
444 · Set C' to C.
445
446 · Replace each parent P of C' with its simplification P'. In the
447 process, drop parents that are ancestors of other parents, and
448 remove duplicates.
449
450 · If after this parent rewriting, C' is a root or merge commit
451 (has zero or >1 parents), a boundary commit, or !TREESAME, it
452 remains. Otherwise, it is replaced with its only parent.
453
454 The effect of this is best shown by way of comparing to
455 --full-history with parent rewriting. The example turns into:
456
457 .-A---M---N---O
458 / / /
459 I B D
460 \ / /
461 `---------'
462
463 Note the major differences in N and P over --full-history:
464
465 · N's parent list had I removed, because it is an ancestor of the
466 other parent M. Still, N remained because it is !TREESAME.
467
468 · P's parent list similarly had I removed. P was then removed
469 completely, because it had one parent and is TREESAME.
470
471 Finally, there is a fifth simplification mode available:
472
473 --ancestry-path
474 Limit the displayed commits to those directly on the ancestry chain
475 between the "from" and "to" commits in the given commit range. I.e.
476 only display commits that are ancestor of the "to" commit, and
477 descendants of the "from" commit.
478
479 As an example use case, consider the following commit history:
480
481 D---E-------F
482 / \ \
483 B---C---G---H---I---J
484 / \
485 A-------K---------------L--M
486
487 A regular D..M computes the set of commits that are ancestors of M,
488 but excludes the ones that are ancestors of D. This is useful to
489 see what happened to the history leading to M since D, in the sense
490 that "what does M have that did not exist in D". The result in this
491 example would be all the commits, except A and B (and D itself, of
492 course).
493
494 When we want to find out what commits in M are contaminated with
495 the bug introduced by D and need fixing, however, we might want to
496 view only the subset of D..M that are actually descendants of D,
497 i.e. excluding C and K. This is exactly what the --ancestry-path
498 option does. Applied to the D..M range, it results in:
499
500 E-------F
501 \ \
502 G---H---I---J
503 \
504 L--M
505
506
507 The --simplify-by-decoration option allows you to view only the big
508 picture of the topology of the history, by omitting commits that are
509 not referenced by tags. Commits are marked as !TREESAME (in other
510 words, kept after history simplification rules described above) if (1)
511 they are referenced by tags, or (2) they change the contents of the
512 paths given on the command line. All other commits are marked as
513 TREESAME (subject to be simplified away).
514
515 Commit Ordering
516 By default, the commits are shown in reverse chronological order.
517
518 --date-order
519 Show no parents before all of its children are shown, but otherwise
520 show commits in the commit timestamp order.
521
522 --topo-order
523 Show no parents before all of its children are shown, and avoid
524 showing commits on multiple lines of history intermixed.
525
526 For example, in a commit history like this:
527
528 ---1----2----4----7
529 \ \
530 3----5----6----8---
531
532 where the numbers denote the order of commit timestamps, git
533 rev-list and friends with --date-order show the commits in the
534 timestamp order: 8 7 6 5 4 3 2 1.
535
536 With --topo-order, they would show 8 6 5 3 7 4 2 1 (or 8 7 4 2 6 5
537 3 1); some older commits are shown before newer ones in order to
538 avoid showing the commits from two parallel development track mixed
539 together.
540
541 --reverse
542 Output the commits in reverse order. Cannot be combined with
543 --walk-reflogs.
544
545 Object Traversal
546 These options are mostly targeted for packing of Git repositories.
547
548 --objects
549 Print the object IDs of any object referenced by the listed
550 commits. --objects foo ^bar thus means "send me all object IDs
551 which I need to download if I have the commit object bar, but not
552 foo".
553
554 --objects-edge
555 Similar to --objects, but also print the IDs of excluded commits
556 prefixed with a "-" character. This is used by git-pack-objects(1)
557 to build "thin" pack, which records objects in deltified form based
558 on objects contained in these excluded commits to reduce network
559 traffic.
560
561 --unpacked
562 Only useful with --objects; print the object IDs that are not in
563 packs.
564
565 --no-walk[=(sorted|unsorted)]
566 Only show the given commits, but do not traverse their ancestors.
567 This has no effect if a range is specified. If the argument
568 "unsorted" is given, the commits are show in the order they were
569 given on the command line. Otherwise (if "sorted" or no argument
570 was given), the commits are show in reverse chronological order by
571 commit time.
572
573 --do-walk
574 Overrides a previous --no-walk.
575
576 Commit Formatting
577 --pretty[=<format>], --format=<format>
578 Pretty-print the contents of the commit logs in a given format,
579 where <format> can be one of oneline, short, medium, full, fuller,
580 email, raw and format:<string>. See the "PRETTY FORMATS" section
581 for some additional details for each format. When omitted, the
582 format defaults to medium.
583
584 Note: you can specify the default pretty format in the repository
585 configuration (see git-config(1)).
586
587 --abbrev-commit
588 Instead of showing the full 40-byte hexadecimal commit object name,
589 show only a partial prefix. Non default number of digits can be
590 specified with "--abbrev=<n>" (which also modifies diff output, if
591 it is displayed).
592
593 This should make "--pretty=oneline" a whole lot more readable for
594 people using 80-column terminals.
595
596 --no-abbrev-commit
597 Show the full 40-byte hexadecimal commit object name. This negates
598 --abbrev-commit and those options which imply it such as
599 "--oneline". It also overrides the log.abbrevCommit variable.
600
601 --oneline
602 This is a shorthand for "--pretty=oneline --abbrev-commit" used
603 together.
604
605 --encoding[=<encoding>]
606 The commit objects record the encoding used for the log message in
607 their encoding header; this option can be used to tell the command
608 to re-code the commit log message in the encoding preferred by the
609 user. For non plumbing commands this defaults to UTF-8.
610
611 --notes[=<ref>]
612 Show the notes (see git-notes(1)) that annotate the commit, when
613 showing the commit log message. This is the default for git log,
614 git show and git whatchanged commands when there is no --pretty,
615 --format nor --oneline option given on the command line.
616
617 By default, the notes shown are from the notes refs listed in the
618 core.notesRef and notes.displayRef variables (or corresponding
619 environment overrides). See git-config(1) for more details.
620
621 With an optional <ref> argument, show this notes ref instead of the
622 default notes ref(s). The ref is taken to be in refs/notes/ if it
623 is not qualified.
624
625 Multiple --notes options can be combined to control which notes are
626 being displayed. Examples: "--notes=foo" will show only notes from
627 "refs/notes/foo"; "--notes=foo --notes" will show both notes from
628 "refs/notes/foo" and from the default notes ref(s).
629
630 --no-notes
631 Do not show notes. This negates the above --notes option, by
632 resetting the list of notes refs from which notes are shown.
633 Options are parsed in the order given on the command line, so e.g.
634 "--notes --notes=foo --no-notes --notes=bar" will only show notes
635 from "refs/notes/bar".
636
637 --show-notes[=<ref>], --[no-]standard-notes
638 These options are deprecated. Use the above --notes/--no-notes
639 options instead.
640
641 --show-signature
642 Check the validity of a signed commit object by passing the
643 signature to gpg --verify and show the output.
644
645 --relative-date
646 Synonym for --date=relative.
647
648 --date=(relative|local|default|iso|rfc|short|raw)
649 Only takes effect for dates shown in human-readable format, such as
650 when using "--pretty". log.date config variable sets a default
651 value for log command’s --date option.
652
653 --date=relative shows dates relative to the current time, e.g. "2
654 hours ago".
655
656 --date=local shows timestamps in user’s local timezone.
657
658 --date=iso (or --date=iso8601) shows timestamps in ISO 8601 format.
659
660 --date=rfc (or --date=rfc2822) shows timestamps in RFC 2822 format,
661 often found in E-mail messages.
662
663 --date=short shows only date but not time, in YYYY-MM-DD format.
664
665 --date=raw shows the date in the internal raw Git format %s %z
666 format.
667
668 --date=default shows timestamps in the original timezone (either
669 committer’s or author’s).
670
671 --parents
672 Print also the parents of the commit (in the form "commit
673 parent..."). Also enables parent rewriting, see History
674 Simplification below.
675
676 --children
677 Print also the children of the commit (in the form "commit
678 child..."). Also enables parent rewriting, see History
679 Simplification below.
680
681 --left-right
682 Mark which side of a symmetric diff a commit is reachable from.
683 Commits from the left side are prefixed with < and those from the
684 right with >. If combined with --boundary, those commits are
685 prefixed with -.
686
687 For example, if you have this topology:
688
689 y---b---b branch B
690 / \ /
691 / .
692 / / \
693 o---x---a---a branch A
694
695 you would get an output like this:
696
697 $ git rev-list --left-right --boundary --pretty=oneline A...B
698
699 >bbbbbbb... 3rd on b
700 >bbbbbbb... 2nd on b
701 <aaaaaaa... 3rd on a
702 <aaaaaaa... 2nd on a
703 -yyyyyyy... 1st on b
704 -xxxxxxx... 1st on a
705
706
707 --graph
708 Draw a text-based graphical representation of the commit history on
709 the left hand side of the output. This may cause extra lines to be
710 printed in between commits, in order for the graph history to be
711 drawn properly.
712
713 This enables parent rewriting, see History Simplification below.
714
715 This implies the --topo-order option by default, but the
716 --date-order option may also be specified.
717
718 Diff Formatting
719 Below are listed options that control the formatting of diff output.
720 Some of them are specific to git-rev-list(1), however other diff
721 options may be given. See git-diff-files(1) for more options.
722
723 -c
724 With this option, diff output for a merge commit shows the
725 differences from each of the parents to the merge result
726 simultaneously instead of showing pairwise diff between a parent
727 and the result one at a time. Furthermore, it lists only files
728 which were modified from all parents.
729
730 --cc
731 This flag implies the -c option and further compresses the patch
732 output by omitting uninteresting hunks whose contents in the
733 parents have only two variants and the merge result picks one of
734 them without modification.
735
736 -m
737 This flag makes the merge commits show the full diff like regular
738 commits; for each merge parent, a separate log entry and diff is
739 generated. An exception is that only diff against the first parent
740 is shown when --first-parent option is given; in that case, the
741 output represents the changes the merge brought into the
742 then-current branch.
743
744 -r
745 Show recursive diffs.
746
747 -t
748 Show the tree objects in the diff output. This implies -r.
749
750 -s
751 Suppress diff output.
752
754 If the commit is a merge, and if the pretty-format is not oneline,
755 email or raw, an additional line is inserted before the Author: line.
756 This line begins with "Merge: " and the sha1s of ancestral commits are
757 printed, separated by spaces. Note that the listed commits may not
758 necessarily be the list of the direct parent commits if you have
759 limited your view of history: for example, if you are only interested
760 in changes related to a certain directory or file.
761
762 There are several built-in formats, and you can define additional
763 formats by setting a pretty.<name> config option to either another
764 format name, or a format: string, as described below (see git-
765 config(1)). Here are the details of the built-in formats:
766
767 · oneline
768
769 <sha1> <title line>
770
771 This is designed to be as compact as possible.
772
773 · short
774
775 commit <sha1>
776 Author: <author>
777
778 <title line>
779
780 · medium
781
782 commit <sha1>
783 Author: <author>
784 Date: <author date>
785
786 <title line>
787
788 <full commit message>
789
790 · full
791
792 commit <sha1>
793 Author: <author>
794 Commit: <committer>
795
796 <title line>
797
798 <full commit message>
799
800 · fuller
801
802 commit <sha1>
803 Author: <author>
804 AuthorDate: <author date>
805 Commit: <committer>
806 CommitDate: <committer date>
807
808 <title line>
809
810 <full commit message>
811
812 · email
813
814 From <sha1> <date>
815 From: <author>
816 Date: <author date>
817 Subject: [PATCH] <title line>
818
819 <full commit message>
820
821 · raw
822
823 The raw format shows the entire commit exactly as stored in the
824 commit object. Notably, the SHA-1s are displayed in full,
825 regardless of whether --abbrev or --no-abbrev are used, and parents
826 information show the true parent commits, without taking grafts nor
827 history simplification into account.
828
829 · format:<string>
830
831 The format:<string> format allows you to specify which information
832 you want to show. It works a little bit like printf format, with
833 the notable exception that you get a newline with %n instead of \n.
834
835 E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
836 would show something like this:
837
838 The author of fe6e0ee was Junio C Hamano, 23 hours ago
839 The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
840
841 The placeholders are:
842
843 · %H: commit hash
844
845 · %h: abbreviated commit hash
846
847 · %T: tree hash
848
849 · %t: abbreviated tree hash
850
851 · %P: parent hashes
852
853 · %p: abbreviated parent hashes
854
855 · %an: author name
856
857 · %aN: author name (respecting .mailmap, see git-shortlog(1) or
858 git-blame(1))
859
860 · %ae: author email
861
862 · %aE: author email (respecting .mailmap, see git-shortlog(1) or
863 git-blame(1))
864
865 · %ad: author date (format respects --date= option)
866
867 · %aD: author date, RFC2822 style
868
869 · %ar: author date, relative
870
871 · %at: author date, UNIX timestamp
872
873 · %ai: author date, ISO 8601 format
874
875 · %cn: committer name
876
877 · %cN: committer name (respecting .mailmap, see git-shortlog(1)
878 or git-blame(1))
879
880 · %ce: committer email
881
882 · %cE: committer email (respecting .mailmap, see git-shortlog(1)
883 or git-blame(1))
884
885 · %cd: committer date
886
887 · %cD: committer date, RFC2822 style
888
889 · %cr: committer date, relative
890
891 · %ct: committer date, UNIX timestamp
892
893 · %ci: committer date, ISO 8601 format
894
895 · %d: ref names, like the --decorate option of git-log(1)
896
897 · %e: encoding
898
899 · %s: subject
900
901 · %f: sanitized subject line, suitable for a filename
902
903 · %b: body
904
905 · %B: raw body (unwrapped subject and body)
906
907 · %N: commit notes
908
909 · %GG: raw verification message from GPG for a signed commit
910
911 · %G?: show "G" for a Good signature, "B" for a Bad signature,
912 "U" for a good, untrusted signature and "N" for no signature
913
914 · %GS: show the name of the signer for a signed commit
915
916 · %GK: show the key used to sign a signed commit
917
918 · %gD: reflog selector, e.g., refs/stash@{1}
919
920 · %gd: shortened reflog selector, e.g., stash@{1}
921
922 · %gn: reflog identity name
923
924 · %gN: reflog identity name (respecting .mailmap, see git-
925 shortlog(1) or git-blame(1))
926
927 · %ge: reflog identity email
928
929 · %gE: reflog identity email (respecting .mailmap, see git-
930 shortlog(1) or git-blame(1))
931
932 · %gs: reflog subject
933
934 · %Cred: switch color to red
935
936 · %Cgreen: switch color to green
937
938 · %Cblue: switch color to blue
939
940 · %Creset: reset color
941
942 · %C(...): color specification, as described in color.branch.*
943 config option; adding auto, at the beginning will emit color
944 only when colors are enabled for log output (by color.diff,
945 color.ui, or --color, and respecting the auto settings of the
946 former if we are going to a terminal). auto alone (i.e.
947 %C(auto)) will turn on auto coloring on the next placeholders
948 until the color is switched again.
949
950 · %m: left, right or boundary mark
951
952 · %n: newline
953
954 · %%: a raw %
955
956 · %x00: print a byte from a hex code
957
958 · %w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w
959 option of git-shortlog(1).
960
961 · %<(<N>[,trunc|ltrunc|mtrunc]): make the next placeholder take
962 at least N columns, padding spaces on the right if necessary.
963 Optionally truncate at the beginning (ltrunc), the middle
964 (mtrunc) or the end (trunc) if the output is longer than N
965 columns. Note that truncating only works correctly with N >= 2.
966
967 · %<|(<N>): make the next placeholder take at least until Nth
968 columns, padding spaces on the right if necessary
969
970 · %>(<N>), %>|(<N>): similar to %<(<N>), %<|(<N>) respectively,
971 but padding spaces on the left
972
973 · %>>(<N>), %>>|(<N>): similar to %>(<N>), %>|(<N>) respectively,
974 except that if the next placeholder takes more spaces than
975 given and there are spaces on its left, use those spaces
976
977 · %><(<N>), %><|(<N>): similar to % <(<N>), %<|(<N>)
978 respectively, but padding both sides (i.e. the text is
979 centered)
980
981 Note
982 Some placeholders may depend on other options given to the revision
983 traversal engine. For example, the %g* reflog options will insert
984 an empty string unless we are traversing reflog entries (e.g., by
985 git log -g). The %d placeholder will use the "short" decoration
986 format if --decorate was not already provided on the command line.
987
988 If you add a + (plus sign) after % of a placeholder, a line-feed is
989 inserted immediately before the expansion if and only if the
990 placeholder expands to a non-empty string.
991
992 If you add a - (minus sign) after % of a placeholder, line-feeds that
993 immediately precede the expansion are deleted if and only if the
994 placeholder expands to an empty string.
995
996 If you add a ` ` (space) after % of a placeholder, a space is inserted
997 immediately before the expansion if and only if the placeholder expands
998 to a non-empty string.
999
1000 · tformat:
1001
1002 The tformat: format works exactly like format:, except that it
1003 provides "terminator" semantics instead of "separator" semantics.
1004 In other words, each commit has the message terminator character
1005 (usually a newline) appended, rather than a separator placed
1006 between entries. This means that the final entry of a single-line
1007 format will be properly terminated with a new line, just as the
1008 "oneline" format does. For example:
1009
1010 $ git log -2 --pretty=format:%h 4da45bef \
1011 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1012 4da45be
1013 7134973 -- NO NEWLINE
1014
1015 $ git log -2 --pretty=tformat:%h 4da45bef \
1016 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1017 4da45be
1018 7134973
1019
1020 In addition, any unrecognized string that has a % in it is
1021 interpreted as if it has tformat: in front of it. For example,
1022 these two are equivalent:
1023
1024 $ git log -2 --pretty=tformat:%h 4da45bef
1025 $ git log -2 --pretty=%h 4da45bef
1026
1027
1029 -p, -u, --patch
1030 Generate patch (see section on generating patches).
1031
1032 -U<n>, --unified=<n>
1033 Generate diffs with <n> lines of context instead of the usual
1034 three. Implies -p.
1035
1036 --raw
1037 Generate the raw format.
1038
1039 --patch-with-raw
1040 Synonym for -p --raw.
1041
1042 --minimal
1043 Spend extra time to make sure the smallest possible diff is
1044 produced.
1045
1046 --patience
1047 Generate a diff using the "patience diff" algorithm.
1048
1049 --histogram
1050 Generate a diff using the "histogram diff" algorithm.
1051
1052 --diff-algorithm={patience|minimal|histogram|myers}
1053 Choose a diff algorithm. The variants are as follows:
1054
1055 default, myers
1056 The basic greedy diff algorithm. Currently, this is the
1057 default.
1058
1059 minimal
1060 Spend extra time to make sure the smallest possible diff is
1061 produced.
1062
1063 patience
1064 Use "patience diff" algorithm when generating patches.
1065
1066 histogram
1067 This algorithm extends the patience algorithm to "support
1068 low-occurrence common elements".
1069
1070 For instance, if you configured diff.algorithm variable to a
1071 non-default value and want to use the default one, then you have to
1072 use --diff-algorithm=default option.
1073
1074 --stat[=<width>[,<name-width>[,<count>]]]
1075 Generate a diffstat. By default, as much space as necessary will be
1076 used for the filename part, and the rest for the graph part.
1077 Maximum width defaults to terminal width, or 80 columns if not
1078 connected to a terminal, and can be overridden by <width>. The
1079 width of the filename part can be limited by giving another width
1080 <name-width> after a comma. The width of the graph part can be
1081 limited by using --stat-graph-width=<width> (affects all commands
1082 generating a stat graph) or by setting diff.statGraphWidth=<width>
1083 (does not affect git format-patch). By giving a third parameter
1084 <count>, you can limit the output to the first <count> lines,
1085 followed by ... if there are more.
1086
1087 These parameters can also be set individually with
1088 --stat-width=<width>, --stat-name-width=<name-width> and
1089 --stat-count=<count>.
1090
1091 --numstat
1092 Similar to --stat, but shows number of added and deleted lines in
1093 decimal notation and pathname without abbreviation, to make it more
1094 machine friendly. For binary files, outputs two - instead of saying
1095 0 0.
1096
1097 --shortstat
1098 Output only the last line of the --stat format containing total
1099 number of modified files, as well as number of added and deleted
1100 lines.
1101
1102 --dirstat[=<param1,param2,...>]
1103 Output the distribution of relative amount of changes for each
1104 sub-directory. The behavior of --dirstat can be customized by
1105 passing it a comma separated list of parameters. The defaults are
1106 controlled by the diff.dirstat configuration variable (see git-
1107 config(1)). The following parameters are available:
1108
1109 changes
1110 Compute the dirstat numbers by counting the lines that have
1111 been removed from the source, or added to the destination. This
1112 ignores the amount of pure code movements within a file. In
1113 other words, rearranging lines in a file is not counted as much
1114 as other changes. This is the default behavior when no
1115 parameter is given.
1116
1117 lines
1118 Compute the dirstat numbers by doing the regular line-based
1119 diff analysis, and summing the removed/added line counts. (For
1120 binary files, count 64-byte chunks instead, since binary files
1121 have no natural concept of lines). This is a more expensive
1122 --dirstat behavior than the changes behavior, but it does count
1123 rearranged lines within a file as much as other changes. The
1124 resulting output is consistent with what you get from the other
1125 --*stat options.
1126
1127 files
1128 Compute the dirstat numbers by counting the number of files
1129 changed. Each changed file counts equally in the dirstat
1130 analysis. This is the computationally cheapest --dirstat
1131 behavior, since it does not have to look at the file contents
1132 at all.
1133
1134 cumulative
1135 Count changes in a child directory for the parent directory as
1136 well. Note that when using cumulative, the sum of the
1137 percentages reported may exceed 100%. The default
1138 (non-cumulative) behavior can be specified with the
1139 noncumulative parameter.
1140
1141 <limit>
1142 An integer parameter specifies a cut-off percent (3% by
1143 default). Directories contributing less than this percentage of
1144 the changes are not shown in the output.
1145
1146 Example: The following will count changed files, while ignoring
1147 directories with less than 10% of the total amount of changed
1148 files, and accumulating child directory counts in the parent
1149 directories: --dirstat=files,10,cumulative.
1150
1151 --summary
1152 Output a condensed summary of extended header information such as
1153 creations, renames and mode changes.
1154
1155 --patch-with-stat
1156 Synonym for -p --stat.
1157
1158 -z
1159 Separate the commits with NULs instead of with new newlines.
1160
1161 Also, when --raw or --numstat has been given, do not munge
1162 pathnames and use NULs as output field terminators.
1163
1164 Without this option, each pathname output will have TAB, LF, double
1165 quotes, and backslash characters replaced with \t, \n, \", and \\,
1166 respectively, and the pathname will be enclosed in double quotes if
1167 any of those replacements occurred.
1168
1169 --name-only
1170 Show only names of changed files.
1171
1172 --name-status
1173 Show only names and status of changed files. See the description of
1174 the --diff-filter option on what the status letters mean.
1175
1176 --submodule[=<format>]
1177 Specify how differences in submodules are shown. When --submodule
1178 or --submodule=log is given, the log format is used. This format
1179 lists the commits in the range like git-submodule(1)summary does.
1180 Omitting the --submodule option or specifying --submodule=short,
1181 uses the short format. This format just shows the names of the
1182 commits at the beginning and end of the range. Can be tweaked via
1183 the diff.submodule configuration variable.
1184
1185 --color[=<when>]
1186 Show colored diff. --color (i.e. without =<when>) is the same as
1187 --color=always. <when> can be one of always, never, or auto.
1188
1189 --no-color
1190 Turn off colored diff. It is the same as --color=never.
1191
1192 --word-diff[=<mode>]
1193 Show a word diff, using the <mode> to delimit changed words. By
1194 default, words are delimited by whitespace; see --word-diff-regex
1195 below. The <mode> defaults to plain, and must be one of:
1196
1197 color
1198 Highlight changed words using only colors. Implies --color.
1199
1200 plain
1201 Show words as [-removed-] and {+added+}. Makes no attempts to
1202 escape the delimiters if they appear in the input, so the
1203 output may be ambiguous.
1204
1205 porcelain
1206 Use a special line-based format intended for script
1207 consumption. Added/removed/unchanged runs are printed in the
1208 usual unified diff format, starting with a +/-/` ` character at
1209 the beginning of the line and extending to the end of the line.
1210 Newlines in the input are represented by a tilde ~ on a line of
1211 its own.
1212
1213 none
1214 Disable word diff again.
1215
1216 Note that despite the name of the first mode, color is used to
1217 highlight the changed parts in all modes if enabled.
1218
1219 --word-diff-regex=<regex>
1220 Use <regex> to decide what a word is, instead of considering runs
1221 of non-whitespace to be a word. Also implies --word-diff unless it
1222 was already enabled.
1223
1224 Every non-overlapping match of the <regex> is considered a word.
1225 Anything between these matches is considered whitespace and
1226 ignored(!) for the purposes of finding differences. You may want to
1227 append |[^[:space:]] to your regular expression to make sure that
1228 it matches all non-whitespace characters. A match that contains a
1229 newline is silently truncated(!) at the newline.
1230
1231 The regex can also be set via a diff driver or configuration
1232 option, see gitattributes(1) or git-config(1). Giving it explicitly
1233 overrides any diff driver or configuration setting. Diff drivers
1234 override configuration settings.
1235
1236 --color-words[=<regex>]
1237 Equivalent to --word-diff=color plus (if a regex was specified)
1238 --word-diff-regex=<regex>.
1239
1240 --no-renames
1241 Turn off rename detection, even when the configuration file gives
1242 the default to do so.
1243
1244 --check
1245 Warn if changes introduce whitespace errors. What are considered
1246 whitespace errors is controlled by core.whitespace configuration.
1247 By default, trailing whitespaces (including lines that solely
1248 consist of whitespaces) and a space character that is immediately
1249 followed by a tab character inside the initial indent of the line
1250 are considered whitespace errors. Exits with non-zero status if
1251 problems are found. Not compatible with --exit-code.
1252
1253 --full-index
1254 Instead of the first handful of characters, show the full pre- and
1255 post-image blob object names on the "index" line when generating
1256 patch format output.
1257
1258 --binary
1259 In addition to --full-index, output a binary diff that can be
1260 applied with git-apply.
1261
1262 --abbrev[=<n>]
1263 Instead of showing the full 40-byte hexadecimal object name in
1264 diff-raw format output and diff-tree header lines, show only a
1265 partial prefix. This is independent of the --full-index option
1266 above, which controls the diff-patch output format. Non default
1267 number of digits can be specified with --abbrev=<n>.
1268
1269 -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
1270 Break complete rewrite changes into pairs of delete and create.
1271 This serves two purposes:
1272
1273 It affects the way a change that amounts to a total rewrite of a
1274 file not as a series of deletion and insertion mixed together with
1275 a very few lines that happen to match textually as the context, but
1276 as a single deletion of everything old followed by a single
1277 insertion of everything new, and the number m controls this aspect
1278 of the -B option (defaults to 60%). -B/70% specifies that less
1279 than 30% of the original should remain in the result for Git to
1280 consider it a total rewrite (i.e. otherwise the resulting patch
1281 will be a series of deletion and insertion mixed together with
1282 context lines).
1283
1284 When used with -M, a totally-rewritten file is also considered as
1285 the source of a rename (usually -M only considers a file that
1286 disappeared as the source of a rename), and the number n controls
1287 this aspect of the -B option (defaults to 50%). -B20% specifies
1288 that a change with addition and deletion compared to 20% or more of
1289 the file’s size are eligible for being picked up as a possible
1290 source of a rename to another file.
1291
1292 -M[<n>], --find-renames[=<n>]
1293 If generating diffs, detect and report renames for each commit. For
1294 following files across renames while traversing history, see
1295 --follow. If n is specified, it is a threshold on the similarity
1296 index (i.e. amount of addition/deletions compared to the file’s
1297 size). For example, -M90% means Git should consider a delete/add
1298 pair to be a rename if more than 90% of the file hasn’t changed.
1299 Without a % sign, the number is to be read as a fraction, with a
1300 decimal point before it. I.e., -M5 becomes 0.5, and is thus the
1301 same as -M50%. Similarly, -M05 is the same as -M5%. To limit
1302 detection to exact renames, use -M100%.
1303
1304 -C[<n>], --find-copies[=<n>]
1305 Detect copies as well as renames. See also --find-copies-harder. If
1306 n is specified, it has the same meaning as for -M<n>.
1307
1308 --find-copies-harder
1309 For performance reasons, by default, -C option finds copies only if
1310 the original file of the copy was modified in the same changeset.
1311 This flag makes the command inspect unmodified files as candidates
1312 for the source of copy. This is a very expensive operation for
1313 large projects, so use it with caution. Giving more than one -C
1314 option has the same effect.
1315
1316 -D, --irreversible-delete
1317 Omit the preimage for deletes, i.e. print only the header but not
1318 the diff between the preimage and /dev/null. The resulting patch is
1319 not meant to be applied with patch nor git apply; this is solely
1320 for people who want to just concentrate on reviewing the text after
1321 the change. In addition, the output obviously lack enough
1322 information to apply such a patch in reverse, even manually, hence
1323 the name of the option.
1324
1325 When used together with -B, omit also the preimage in the deletion
1326 part of a delete/create pair.
1327
1328 -l<num>
1329 The -M and -C options require O(n^2) processing time where n is the
1330 number of potential rename/copy targets. This option prevents
1331 rename/copy detection from running if the number of rename/copy
1332 targets exceeds the specified number.
1333
1334 --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
1335 Select only files that are Added (A), Copied (C), Deleted (D),
1336 Modified (M), Renamed (R), have their type (i.e. regular file,
1337 symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
1338 (X), or have had their pairing Broken (B). Any combination of the
1339 filter characters (including none) can be used. When *
1340 (All-or-none) is added to the combination, all paths are selected
1341 if there is any file that matches other criteria in the comparison;
1342 if there is no file that matches other criteria, nothing is
1343 selected.
1344
1345 -S<string>
1346 Look for differences that introduce or remove an instance of
1347 <string>. Note that this is different than the string simply
1348 appearing in diff output; see the pickaxe entry in gitdiffcore(7)
1349 for more details.
1350
1351 -G<regex>
1352 Look for differences whose added or removed line matches the given
1353 <regex>.
1354
1355 --pickaxe-all
1356 When -S or -G finds a change, show all the changes in that
1357 changeset, not just the files that contain the change in <string>.
1358
1359 --pickaxe-regex
1360 Make the <string> not a plain string but an extended POSIX regex to
1361 match.
1362
1363 -O<orderfile>
1364 Output the patch in the order specified in the <orderfile>, which
1365 has one shell glob pattern per line.
1366
1367 -R
1368 Swap two inputs; that is, show differences from index or on-disk
1369 file to tree contents.
1370
1371 --relative[=<path>]
1372 When run from a subdirectory of the project, it can be told to
1373 exclude changes outside the directory and show pathnames relative
1374 to it with this option. When you are not in a subdirectory (e.g. in
1375 a bare repository), you can name which subdirectory to make the
1376 output relative to by giving a <path> as an argument.
1377
1378 -a, --text
1379 Treat all files as text.
1380
1381 --ignore-space-at-eol
1382 Ignore changes in whitespace at EOL.
1383
1384 -b, --ignore-space-change
1385 Ignore changes in amount of whitespace. This ignores whitespace at
1386 line end, and considers all other sequences of one or more
1387 whitespace characters to be equivalent.
1388
1389 -w, --ignore-all-space
1390 Ignore whitespace when comparing lines. This ignores differences
1391 even if one line has whitespace where the other line has none.
1392
1393 --inter-hunk-context=<lines>
1394 Show the context between diff hunks, up to the specified number of
1395 lines, thereby fusing hunks that are close to each other.
1396
1397 -W, --function-context
1398 Show whole surrounding functions of changes.
1399
1400 --ext-diff
1401 Allow an external diff helper to be executed. If you set an
1402 external diff driver with gitattributes(5), you need to use this
1403 option with git-log(1) and friends.
1404
1405 --no-ext-diff
1406 Disallow external diff drivers.
1407
1408 --textconv, --no-textconv
1409 Allow (or disallow) external text conversion filters to be run when
1410 comparing binary files. See gitattributes(5) for details. Because
1411 textconv filters are typically a one-way conversion, the resulting
1412 diff is suitable for human consumption, but cannot be applied. For
1413 this reason, textconv filters are enabled by default only for git-
1414 diff(1) and git-log(1), but not for git-format-patch(1) or diff
1415 plumbing commands.
1416
1417 --ignore-submodules[=<when>]
1418 Ignore changes to submodules in the diff generation. <when> can be
1419 either "none", "untracked", "dirty" or "all", which is the default.
1420 Using "none" will consider the submodule modified when it either
1421 contains untracked or modified files or its HEAD differs from the
1422 commit recorded in the superproject and can be used to override any
1423 settings of the ignore option in git-config(1) or gitmodules(5).
1424 When "untracked" is used submodules are not considered dirty when
1425 they only contain untracked content (but they are still scanned for
1426 modified content). Using "dirty" ignores all changes to the work
1427 tree of submodules, only changes to the commits stored in the
1428 superproject are shown (this was the behavior until 1.7.0). Using
1429 "all" hides all changes to submodules.
1430
1431 --src-prefix=<prefix>
1432 Show the given source prefix instead of "a/".
1433
1434 --dst-prefix=<prefix>
1435 Show the given destination prefix instead of "b/".
1436
1437 --no-prefix
1438 Do not show any source or destination prefix.
1439
1440 For more detailed explanation on these common options, see also
1441 gitdiffcore(7).
1442
1444 When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1445 with a -p option, "git diff" without the --raw option, or "git log"
1446 with the "-p" option, they do not produce the output described above;
1447 instead they produce a patch file. You can customize the creation of
1448 such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
1449 environment variables.
1450
1451 What the -p option produces is slightly different from the traditional
1452 diff format:
1453
1454 1. It is preceded with a "git diff" header that looks like this:
1455
1456 diff --git a/file1 b/file2
1457
1458 The a/ and b/ filenames are the same unless rename/copy is
1459 involved. Especially, even for a creation or a deletion, /dev/null
1460 is not used in place of the a/ or b/ filenames.
1461
1462 When rename/copy is involved, file1 and file2 show the name of the
1463 source file of the rename/copy and the name of the file that
1464 rename/copy produces, respectively.
1465
1466 2. It is followed by one or more extended header lines:
1467
1468 old mode <mode>
1469 new mode <mode>
1470 deleted file mode <mode>
1471 new file mode <mode>
1472 copy from <path>
1473 copy to <path>
1474 rename from <path>
1475 rename to <path>
1476 similarity index <number>
1477 dissimilarity index <number>
1478 index <hash>..<hash> <mode>
1479
1480 File modes are printed as 6-digit octal numbers including the file
1481 type and file permission bits.
1482
1483 Path names in extended headers do not include the a/ and b/
1484 prefixes.
1485
1486 The similarity index is the percentage of unchanged lines, and the
1487 dissimilarity index is the percentage of changed lines. It is a
1488 rounded down integer, followed by a percent sign. The similarity
1489 index value of 100% is thus reserved for two equal files, while
1490 100% dissimilarity means that no line from the old file made it
1491 into the new one.
1492
1493 The index line includes the SHA-1 checksum before and after the
1494 change. The <mode> is included if the file mode does not change;
1495 otherwise, separate lines indicate the old and the new mode.
1496
1497 3. TAB, LF, double quote and backslash characters in pathnames are
1498 represented as \t, \n, \" and \\, respectively. If there is need
1499 for such substitution then the whole pathname is put in double
1500 quotes.
1501
1502 4. All the file1 files in the output refer to files before the commit,
1503 and all the file2 files refer to files after the commit. It is
1504 incorrect to apply each change to each file sequentially. For
1505 example, this patch will swap a and b:
1506
1507 diff --git a/a b/b
1508 rename from a
1509 rename to b
1510 diff --git a/b b/a
1511 rename from b
1512 rename to a
1513
1515 Any diff-generating command can take the ‘-c` or --cc option to produce
1516 a combined diff when showing a merge. This is the default format when
1517 showing merges with git-diff(1) or git-show(1). Note also that you can
1518 give the `-m’ option to any of these commands to force generation of
1519 diffs with individual parents of a merge.
1520
1521 A combined diff format looks like this:
1522
1523 diff --combined describe.c
1524 index fabadb8,cc95eb0..4866510
1525 --- a/describe.c
1526 +++ b/describe.c
1527 @@@ -98,20 -98,12 +98,20 @@@
1528 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1529 }
1530
1531 - static void describe(char *arg)
1532 -static void describe(struct commit *cmit, int last_one)
1533 ++static void describe(char *arg, int last_one)
1534 {
1535 + unsigned char sha1[20];
1536 + struct commit *cmit;
1537 struct commit_list *list;
1538 static int initialized = 0;
1539 struct commit_name *n;
1540
1541 + if (get_sha1(arg, sha1) < 0)
1542 + usage(describe_usage);
1543 + cmit = lookup_commit_reference(sha1);
1544 + if (!cmit)
1545 + usage(describe_usage);
1546 +
1547 if (!initialized) {
1548 initialized = 1;
1549 for_each_ref(get_name);
1550
1551
1552
1553 1. It is preceded with a "git diff" header, that looks like this (when
1554 -c option is used):
1555
1556 diff --combined file
1557
1558 or like this (when --cc option is used):
1559
1560 diff --cc file
1561
1562 2. It is followed by one or more extended header lines (this example
1563 shows a merge with two parents):
1564
1565 index <hash>,<hash>..<hash>
1566 mode <mode>,<mode>..<mode>
1567 new file mode <mode>
1568 deleted file mode <mode>,<mode>
1569
1570 The mode <mode>,<mode>..<mode> line appears only if at least one of
1571 the <mode> is different from the rest. Extended headers with
1572 information about detected contents movement (renames and copying
1573 detection) are designed to work with diff of two <tree-ish> and are
1574 not used by combined diff format.
1575
1576 3. It is followed by two-line from-file/to-file header
1577
1578 --- a/file
1579 +++ b/file
1580
1581 Similar to two-line header for traditional unified diff format,
1582 /dev/null is used to signal created or deleted files.
1583
1584 4. Chunk header format is modified to prevent people from accidentally
1585 feeding it to patch -p1. Combined diff format was created for
1586 review of merge commit changes, and was not meant for apply. The
1587 change is similar to the change in the extended index header:
1588
1589 @@@ <from-file-range> <from-file-range> <to-file-range> @@@
1590
1591 There are (number of parents + 1) @ characters in the chunk header
1592 for combined diff format.
1593
1594 Unlike the traditional unified diff format, which shows two files A and
1595 B with a single column that has - (minus — appears in A but removed in
1596 B), + (plus — missing in A but added to B), or " " (space — unchanged)
1597 prefix, this format compares two or more files file1, file2,... with
1598 one file X, and shows how X differs from each of fileN. One column for
1599 each of fileN is prepended to the output line to note how X’s line is
1600 different from it.
1601
1602 A - character in the column N means that the line appears in fileN but
1603 it does not appear in the result. A + character in the column N means
1604 that the line appears in the result, and fileN does not have that line
1605 (in other words, the line was added, from the point of view of that
1606 parent).
1607
1608 In the above example output, the function signature was changed from
1609 both files (hence two - removals from both file1 and file2, plus ++ to
1610 mean one line that was added does not appear in either file1 nor
1611 file2). Also eight other lines are the same from file1 but do not
1612 appear in file2 (hence prefixed with +).
1613
1614 When shown by git diff-tree -c, it compares the parents of a merge
1615 commit with the merge result (i.e. file1..fileN are the parents). When
1616 shown by git diff-files -c, it compares the two unresolved merge
1617 parents with the working tree file (i.e. file1 is stage 2 aka "our
1618 version", file2 is stage 3 aka "their version").
1619
1621 git log --no-merges
1622 Show the whole commit history, but skip any merges
1623
1624 git log v2.6.12.. include/scsi drivers/scsi
1625 Show all commits since version v2.6.12 that changed any file in the
1626 include/scsi or drivers/scsi subdirectories
1627
1628 git log --since="2 weeks ago" -- gitk
1629 Show the changes during the last two weeks to the file gitk. The
1630 "--" is necessary to avoid confusion with the branch named gitk
1631
1632 git log --name-status release..test
1633 Show the commits that are in the "test" branch but not yet in the
1634 "release" branch, along with the list of paths each commit
1635 modifies.
1636
1637 git log --follow builtin-rev-list.c
1638 Shows the commits that changed builtin-rev-list.c, including those
1639 commits that occurred before the file was given its present name.
1640
1641 git log --branches --not --remotes=origin
1642 Shows all commits that are in any of local branches but not in any
1643 of remote-tracking branches for origin (what you have that origin
1644 doesn’t).
1645
1646 git log master --not --remotes=*/master
1647 Shows all commits that are in local master but not in any remote
1648 repository master branches.
1649
1650 git log -p -m --first-parent
1651 Shows the history including change diffs, but only from the "main
1652 branch" perspective, skipping commits that come from merged
1653 branches, and showing full diffs of changes introduced by the
1654 merges. This makes sense only when following a strict policy of
1655 merging all topic branches when staying on a single integration
1656 branch.
1657
1658 git log -3
1659 Limits the number of commits to show to 3.
1660
1662 At the core level, Git is character encoding agnostic.
1663
1664 · The pathnames recorded in the index and in the tree objects are
1665 treated as uninterpreted sequences of non-NUL bytes. What
1666 readdir(2) returns are what are recorded and compared with the data
1667 Git keeps track of, which in turn are expected to be what lstat(2)
1668 and creat(2) accepts. There is no such thing as pathname encoding
1669 translation.
1670
1671 · The contents of the blob objects are uninterpreted sequences of
1672 bytes. There is no encoding translation at the core level.
1673
1674 · The commit log messages are uninterpreted sequences of non-NUL
1675 bytes.
1676
1677 Although we encourage that the commit log messages are encoded in
1678 UTF-8, both the core and Git Porcelain are designed not to force UTF-8
1679 on projects. If all participants of a particular project find it more
1680 convenient to use legacy encodings, Git does not forbid it. However,
1681 there are a few things to keep in mind.
1682
1683 1. git commit and git commit-tree issues a warning if the commit log
1684 message given to it does not look like a valid UTF-8 string, unless
1685 you explicitly say your project uses a legacy encoding. The way to
1686 say this is to have i18n.commitencoding in .git/config file, like
1687 this:
1688
1689 [i18n]
1690 commitencoding = ISO-8859-1
1691
1692 Commit objects created with the above setting record the value of
1693 i18n.commitencoding in its encoding header. This is to help other
1694 people who look at them later. Lack of this header implies that the
1695 commit log message is encoded in UTF-8.
1696
1697 2. git log, git show, git blame and friends look at the encoding
1698 header of a commit object, and try to re-code the log message into
1699 UTF-8 unless otherwise specified. You can specify the desired
1700 output encoding with i18n.logoutputencoding in .git/config file,
1701 like this:
1702
1703 [i18n]
1704 logoutputencoding = ISO-8859-1
1705
1706 If you do not have this configuration variable, the value of
1707 i18n.commitencoding is used instead.
1708
1709 Note that we deliberately chose not to re-code the commit log message
1710 when a commit is made to force UTF-8 at the commit object level,
1711 because re-coding to UTF-8 is not necessarily a reversible operation.
1712
1714 See git-config(1) for core variables and git-diff(1) for settings
1715 related to diff generation.
1716
1717 format.pretty
1718 Default for the --format option. (See "PRETTY FORMATS" above.)
1719 Defaults to "medium".
1720
1721 i18n.logOutputEncoding
1722 Encoding to use when displaying logs. (See "Discussion", above.)
1723 Defaults to the value of i18n.commitEncoding if set, UTF-8
1724 otherwise.
1725
1726 log.date
1727 Default format for human-readable dates. (Compare the --date
1728 option.) Defaults to "default", which means to write dates like Sat
1729 May 8 19:35:34 2010 -0500.
1730
1731 log.showroot
1732 If false, git log and related commands will not treat the initial
1733 commit as a big creation event. Any root commits in git log -p
1734 output would be shown without a diff attached. The default is true.
1735
1736 mailmap.*
1737 See git-shortlog(1).
1738
1739 notes.displayRef
1740 Which refs, in addition to the default set by core.notesRef or
1741 GIT_NOTES_REF, to read notes from when showing commit messages with
1742 the log family of commands. See git-notes(1).
1743
1744 May be an unabbreviated ref name or a glob and may be specified
1745 multiple times. A warning will be issued for refs that do not
1746 exist, but a glob that does not match any refs is silently ignored.
1747
1748 This setting can be disabled by the --no-notes option, overridden
1749 by the GIT_NOTES_DISPLAY_REF environment variable, and overridden
1750 by the --notes=<ref> option.
1751
1753 Part of the git(1) suite
1754
1755
1756
1757Git 1.8.3.1 11/19/2018 GIT-LOG(1)