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
12 Shows the commit logs.
13
14 List commits that are reachable by following the parent links from the
15 given commit(s), but exclude commits that are reachable from the one(s)
16 given with a ^ in front of them. The output is given in reverse
17 chronological order by default.
18
19 You can think of this as a set operation. Commits reachable from any of
20 the commits given on the command line form a set, and then commits
21 reachable from any of the ones given with ^ in front are subtracted
22 from that set. The remaining commits are what comes out in the
23 command’s output. Various other options and paths parameters can be
24 used to further limit the result.
25
26 Thus, the following command:
27
28 $ git log foo bar ^baz
29
30 means "list all the commits which are reachable from foo or bar, but
31 not from baz".
32
33 A special notation "<commit1>..<commit2>" can be used as a short-hand
34 for "^<commit1> <commit2>". For example, either of the following may be
35 used interchangeably:
36
37 $ git log origin..HEAD
38 $ git log HEAD ^origin
39
40 Another special notation is "<commit1>...<commit2>" which is useful for
41 merges. The resulting set of commits is the symmetric difference
42 between the two operands. The following two commands are equivalent:
43
44 $ git log A B --not $(git merge-base --all A B)
45 $ git log A...B
46
47 The command takes options applicable to the git-rev-list(1) command to
48 control what is shown and how, and options applicable to the git-
49 diff(1) command to control how the changes each commit introduces are
50 shown.
51
53 --follow
54 Continue listing the history of a file beyond renames (works only
55 for a single file).
56
57 --no-decorate, --decorate[=short|full|auto|no]
58 Print out the ref names of any commits that are shown. If short is
59 specified, the ref name prefixes refs/heads/, refs/tags/ and
60 refs/remotes/ will not be printed. If full is specified, the full
61 ref name (including prefix) will be printed. If auto is specified,
62 then if the output is going to a terminal, the ref names are shown
63 as if short were given, otherwise no ref names are shown. The
64 default option is short.
65
66 --decorate-refs=<pattern>, --decorate-refs-exclude=<pattern>
67 If no --decorate-refs is given, pretend as if all refs were
68 included. For each candidate, do not use it for decoration if it
69 matches any patterns given to --decorate-refs-exclude or if it
70 doesn’t match any of the patterns given to --decorate-refs. The
71 log.excludeDecoration config option allows excluding refs from the
72 decorations, but an explicit --decorate-refs pattern will override
73 a match in log.excludeDecoration.
74
75 --source
76 Print out the ref name given on the command line by which each
77 commit was reached.
78
79 --[no-]mailmap, --[no-]use-mailmap
80 Use mailmap file to map author and committer names and email
81 addresses to canonical real names and email addresses. See git-
82 shortlog(1).
83
84 --full-diff
85 Without this flag, git log -p <path>... shows commits that touch
86 the specified paths, and diffs about the same specified paths. With
87 this, the full diff is shown for commits that touch the specified
88 paths; this means that "<path>..." limits only commits, and doesn’t
89 limit diff for those commits.
90
91 Note that this affects all diff-based output types, e.g. those
92 produced by --stat, etc.
93
94 --log-size
95 Include a line “log size <number>” in the output for each commit,
96 where <number> is the length of that commit’s message in bytes.
97 Intended to speed up tools that read log messages from git log
98 output by allowing them to allocate space in advance.
99
100 -L<start>,<end>:<file>, -L:<funcname>:<file>
101 Trace the evolution of the line range given by <start>,<end>, or by
102 the function name regex <funcname>, within the <file>. You may not
103 give any pathspec limiters. This is currently limited to a walk
104 starting from a single revision, i.e., you may only give zero or
105 one positive revision arguments, and <start> and <end> (or
106 <funcname>) must exist in the starting revision. You can specify
107 this option more than once. Implies --patch. Patch output can be
108 suppressed using --no-patch, but other diff formats (namely --raw,
109 --numstat, --shortstat, --dirstat, --summary, --name-only,
110 --name-status, --check) are not currently implemented.
111
112 <start> and <end> can take one of these forms:
113
114 • number
115
116 If <start> or <end> is a number, it specifies an absolute line
117 number (lines count from 1).
118
119 • /regex/
120
121 This form will use the first line matching the given POSIX
122 regex. If <start> is a regex, it will search from the end of
123 the previous -L range, if any, otherwise from the start of
124 file. If <start> is ^/regex/, it will search from the start of
125 file. If <end> is a regex, it will search starting at the line
126 given by <start>.
127
128 • +offset or -offset
129
130 This is only valid for <end> and will specify a number of lines
131 before or after the line given by <start>.
132
133 If :<funcname> is given in place of <start> and <end>, it is a
134 regular expression that denotes the range from the first funcname
135 line that matches <funcname>, up to the next funcname line.
136 :<funcname> searches from the end of the previous -L range, if any,
137 otherwise from the start of file. ^:<funcname> searches from the
138 start of file. The function names are determined in the same way as
139 git diff works out patch hunk headers (see Defining a custom
140 hunk-header in gitattributes(5)).
141
142 <revision range>
143 Show only commits in the specified revision range. When no
144 <revision range> is specified, it defaults to HEAD (i.e. the whole
145 history leading to the current commit). origin..HEAD specifies all
146 the commits reachable from the current commit (i.e. HEAD), but not
147 from origin. For a complete list of ways to spell <revision range>,
148 see the Specifying Ranges section of gitrevisions(7).
149
150 [--] <path>...
151 Show only commits that are enough to explain how the files that
152 match the specified paths came to be. See History Simplification
153 below for details and other simplification modes.
154
155 Paths may need to be prefixed with -- to separate them from options
156 or the revision range, when confusion arises.
157
158 Commit Limiting
159 Besides specifying a range of commits that should be listed using the
160 special notations explained in the description, additional commit
161 limiting may be applied.
162
163 Using more options generally further limits the output (e.g.
164 --since=<date1> limits to commits newer than <date1>, and using it with
165 --grep=<pattern> further limits to commits whose log message has a line
166 that matches <pattern>), unless otherwise noted.
167
168 Note that these are applied before commit ordering and formatting
169 options, such as --reverse.
170
171 -<number>, -n <number>, --max-count=<number>
172 Limit the number of commits to output.
173
174 --skip=<number>
175 Skip number commits before starting to show the commit output.
176
177 --since=<date>, --after=<date>
178 Show commits more recent than a specific date.
179
180 --until=<date>, --before=<date>
181 Show commits older than a specific date.
182
183 --author=<pattern>, --committer=<pattern>
184 Limit the commits output to ones with author/committer header lines
185 that match the specified pattern (regular expression). With more
186 than one --author=<pattern>, commits whose author matches any of
187 the given patterns are chosen (similarly for multiple
188 --committer=<pattern>).
189
190 --grep-reflog=<pattern>
191 Limit the commits output to ones with reflog entries that match the
192 specified pattern (regular expression). With more than one
193 --grep-reflog, commits whose reflog message matches any of the
194 given patterns are chosen. It is an error to use this option unless
195 --walk-reflogs is in use.
196
197 --grep=<pattern>
198 Limit the commits output to ones with log message that matches the
199 specified pattern (regular expression). With more than one
200 --grep=<pattern>, commits whose message matches any of the given
201 patterns are chosen (but see --all-match).
202
203 When --notes is in effect, the message from the notes is matched as
204 if it were part of the log message.
205
206 --all-match
207 Limit the commits output to ones that match all given --grep,
208 instead of ones that match at least one.
209
210 --invert-grep
211 Limit the commits output to ones with log message that do not match
212 the pattern specified with --grep=<pattern>.
213
214 -i, --regexp-ignore-case
215 Match the regular expression limiting patterns without regard to
216 letter case.
217
218 --basic-regexp
219 Consider the limiting patterns to be basic regular expressions;
220 this is the default.
221
222 -E, --extended-regexp
223 Consider the limiting patterns to be extended regular expressions
224 instead of the default basic regular expressions.
225
226 -F, --fixed-strings
227 Consider the limiting patterns to be fixed strings (don’t interpret
228 pattern as a regular expression).
229
230 -P, --perl-regexp
231 Consider the limiting patterns to be Perl-compatible regular
232 expressions.
233
234 Support for these types of regular expressions is an optional
235 compile-time dependency. If Git wasn’t compiled with support for
236 them providing this option will cause it to die.
237
238 --remove-empty
239 Stop when a given path disappears from the tree.
240
241 --merges
242 Print only merge commits. This is exactly the same as
243 --min-parents=2.
244
245 --no-merges
246 Do not print commits with more than one parent. This is exactly the
247 same as --max-parents=1.
248
249 --min-parents=<number>, --max-parents=<number>, --no-min-parents,
250 --no-max-parents
251 Show only commits which have at least (or at most) that many parent
252 commits. In particular, --max-parents=1 is the same as --no-merges,
253 --min-parents=2 is the same as --merges. --max-parents=0 gives all
254 root commits and --min-parents=3 all octopus merges.
255
256 --no-min-parents and --no-max-parents reset these limits (to no
257 limit) again. Equivalent forms are --min-parents=0 (any commit has
258 0 or more parents) and --max-parents=-1 (negative numbers denote no
259 upper limit).
260
261 --first-parent
262 Follow only the first parent commit upon seeing a merge commit.
263 This option can give a better overview when viewing the evolution
264 of a particular topic branch, because merges into a topic branch
265 tend to be only about adjusting to updated upstream from time to
266 time, and this option allows you to ignore the individual commits
267 brought in to your history by such a merge.
268
269 This option also changes default diff format for merge commits to
270 first-parent, see --diff-merges=first-parent for details.
271
272 --not
273 Reverses the meaning of the ^ prefix (or lack thereof) for all
274 following revision specifiers, up to the next --not.
275
276 --all
277 Pretend as if all the refs in refs/, along with HEAD, are listed on
278 the command line as <commit>.
279
280 --branches[=<pattern>]
281 Pretend as if all the refs in refs/heads are listed on the command
282 line as <commit>. If <pattern> is given, limit branches to ones
283 matching given shell glob. If pattern lacks ?, *, or [, /* at the
284 end is implied.
285
286 --tags[=<pattern>]
287 Pretend as if all the refs in refs/tags are listed on the command
288 line as <commit>. If <pattern> is given, limit tags to ones
289 matching given shell glob. If pattern lacks ?, *, or [, /* at the
290 end is implied.
291
292 --remotes[=<pattern>]
293 Pretend as if all the refs in refs/remotes are listed on the
294 command line as <commit>. If <pattern> is given, limit
295 remote-tracking branches to ones matching given shell glob. If
296 pattern lacks ?, *, or [, /* at the end is implied.
297
298 --glob=<glob-pattern>
299 Pretend as if all the refs matching shell glob <glob-pattern> are
300 listed on the command line as <commit>. Leading refs/, is
301 automatically prepended if missing. If pattern lacks ?, *, or [, /*
302 at the end is implied.
303
304 --exclude=<glob-pattern>
305 Do not include refs matching <glob-pattern> that the next --all,
306 --branches, --tags, --remotes, or --glob would otherwise consider.
307 Repetitions of this option accumulate exclusion patterns up to the
308 next --all, --branches, --tags, --remotes, or --glob option (other
309 options or arguments do not clear accumulated patterns).
310
311 The patterns given should not begin with refs/heads, refs/tags, or
312 refs/remotes when applied to --branches, --tags, or --remotes,
313 respectively, and they must begin with refs/ when applied to --glob
314 or --all. If a trailing /* is intended, it must be given
315 explicitly.
316
317 --reflog
318 Pretend as if all objects mentioned by reflogs are listed on the
319 command line as <commit>.
320
321 --alternate-refs
322 Pretend as if all objects mentioned as ref tips of alternate
323 repositories were listed on the command line. An alternate
324 repository is any repository whose object directory is specified in
325 objects/info/alternates. The set of included objects may be
326 modified by core.alternateRefsCommand, etc. See git-config(1).
327
328 --single-worktree
329 By default, all working trees will be examined by the following
330 options when there are more than one (see git-worktree(1)): --all,
331 --reflog and --indexed-objects. This option forces them to examine
332 the current working tree only.
333
334 --ignore-missing
335 Upon seeing an invalid object name in the input, pretend as if the
336 bad input was not given.
337
338 --bisect
339 Pretend as if the bad bisection ref refs/bisect/bad was listed and
340 as if it was followed by --not and the good bisection refs
341 refs/bisect/good-* on the command line.
342
343 --stdin
344 In addition to the <commit> listed on the command line, read them
345 from the standard input. If a -- separator is seen, stop reading
346 commits and start reading paths to limit the result.
347
348 --cherry-mark
349 Like --cherry-pick (see below) but mark equivalent commits with =
350 rather than omitting them, and inequivalent ones with +.
351
352 --cherry-pick
353 Omit any commit that introduces the same change as another commit
354 on the “other side” when the set of commits are limited with
355 symmetric difference.
356
357 For example, if you have two branches, A and B, a usual way to list
358 all commits on only one side of them is with --left-right (see the
359 example below in the description of the --left-right option).
360 However, it shows the commits that were cherry-picked from the
361 other branch (for example, “3rd on b” may be cherry-picked from
362 branch A). With this option, such pairs of commits are excluded
363 from the output.
364
365 --left-only, --right-only
366 List only commits on the respective side of a symmetric difference,
367 i.e. only those which would be marked < resp. > by --left-right.
368
369 For example, --cherry-pick --right-only A...B omits those commits
370 from B which are in A or are patch-equivalent to a commit in A. In
371 other words, this lists the + commits from git cherry A B. More
372 precisely, --cherry-pick --right-only --no-merges gives the exact
373 list.
374
375 --cherry
376 A synonym for --right-only --cherry-mark --no-merges; useful to
377 limit the output to the commits on our side and mark those that
378 have been applied to the other side of a forked history with git
379 log --cherry upstream...mybranch, similar to git cherry upstream
380 mybranch.
381
382 -g, --walk-reflogs
383 Instead of walking the commit ancestry chain, walk reflog entries
384 from the most recent one to older ones. When this option is used
385 you cannot specify commits to exclude (that is, ^commit,
386 commit1..commit2, and commit1...commit2 notations cannot be used).
387
388 With --pretty format other than oneline and reference (for obvious
389 reasons), this causes the output to have two extra lines of
390 information taken from the reflog. The reflog designator in the
391 output may be shown as ref@{Nth} (where Nth is the
392 reverse-chronological index in the reflog) or as ref@{timestamp}
393 (with the timestamp for that entry), depending on a few rules:
394
395 1. If the starting point is specified as ref@{Nth}, show the index
396 format.
397
398 2. If the starting point was specified as ref@{now}, show the
399 timestamp format.
400
401 3. If neither was used, but --date was given on the command line,
402 show the timestamp in the format requested by --date.
403
404 4. Otherwise, show the index format.
405
406 Under --pretty=oneline, the commit message is prefixed with this
407 information on the same line. This option cannot be combined with
408 --reverse. See also git-reflog(1).
409
410 Under --pretty=reference, this information will not be shown at
411 all.
412
413 --merge
414 After a failed merge, show refs that touch files having a conflict
415 and don’t exist on all heads to merge.
416
417 --boundary
418 Output excluded boundary commits. Boundary commits are prefixed
419 with -.
420
421 History Simplification
422 Sometimes you are only interested in parts of the history, for example
423 the commits modifying a particular <path>. But there are two parts of
424 History Simplification, one part is selecting the commits and the other
425 is how to do it, as there are various strategies to simplify the
426 history.
427
428 The following options select the commits to be shown:
429
430 <paths>
431 Commits modifying the given <paths> are selected.
432
433 --simplify-by-decoration
434 Commits that are referred by some branch or tag are selected.
435
436 Note that extra commits can be shown to give a meaningful history.
437
438 The following options affect the way the simplification is performed:
439
440 Default mode
441 Simplifies the history to the simplest history explaining the final
442 state of the tree. Simplest because it prunes some side branches if
443 the end result is the same (i.e. merging branches with the same
444 content)
445
446 --show-pulls
447 Include all commits from the default mode, but also any merge
448 commits that are not TREESAME to the first parent but are TREESAME
449 to a later parent. This mode is helpful for showing the merge
450 commits that "first introduced" a change to a branch.
451
452 --full-history
453 Same as the default mode, but does not prune some history.
454
455 --dense
456 Only the selected commits are shown, plus some to have a meaningful
457 history.
458
459 --sparse
460 All commits in the simplified history are shown.
461
462 --simplify-merges
463 Additional option to --full-history to remove some needless merges
464 from the resulting history, as there are no selected commits
465 contributing to this merge.
466
467 --ancestry-path
468 When given a range of commits to display (e.g. commit1..commit2 or
469 commit2 ^commit1), only display commits that exist directly on the
470 ancestry chain between the commit1 and commit2, i.e. commits that
471 are both descendants of commit1, and ancestors of commit2.
472
473 A more detailed explanation follows.
474
475 Suppose you specified foo as the <paths>. We shall call commits that
476 modify foo !TREESAME, and the rest TREESAME. (In a diff filtered for
477 foo, they look different and equal, respectively.)
478
479 In the following, we will always refer to the same example history to
480 illustrate the differences between simplification settings. We assume
481 that you are filtering for a file foo in this commit graph:
482
483 .-A---M---N---O---P---Q
484 / / / / / /
485 I B C D E Y
486 \ / / / / /
487 `-------------' X
488
489 The horizontal line of history A---Q is taken to be the first parent of
490 each merge. The commits are:
491
492 • I is the initial commit, in which foo exists with contents “asdf”,
493 and a file quux exists with contents “quux”. Initial commits are
494 compared to an empty tree, so I is !TREESAME.
495
496 • In A, foo contains just “foo”.
497
498 • B contains the same change as A. Its merge M is trivial and hence
499 TREESAME to all parents.
500
501 • C does not change foo, but its merge N changes it to “foobar”, so
502 it is not TREESAME to any parent.
503
504 • D sets foo to “baz”. Its merge O combines the strings from N and D
505 to “foobarbaz”; i.e., it is not TREESAME to any parent.
506
507 • E changes quux to “xyzzy”, and its merge P combines the strings to
508 “quux xyzzy”. P is TREESAME to O, but not to E.
509
510 • X is an independent root commit that added a new file side, and Y
511 modified it. Y is TREESAME to X. Its merge Q added side to P, and
512 Q is TREESAME to P, but not to Y.
513
514 rev-list walks backwards through history, including or excluding
515 commits based on whether --full-history and/or parent rewriting (via
516 --parents or --children) are used. The following settings are
517 available.
518
519 Default mode
520 Commits are included if they are not TREESAME to any parent (though
521 this can be changed, see --sparse below). If the commit was a
522 merge, and it was TREESAME to one parent, follow only that parent.
523 (Even if there are several TREESAME parents, follow only one of
524 them.) Otherwise, follow all parents.
525
526 This results in:
527
528 .-A---N---O
529 / / /
530 I---------D
531
532 Note how the rule to only follow the TREESAME parent, if one is
533 available, removed B from consideration entirely. C was considered
534 via N, but is TREESAME. Root commits are compared to an empty tree,
535 so I is !TREESAME.
536
537 Parent/child relations are only visible with --parents, but that
538 does not affect the commits selected in default mode, so we have
539 shown the parent lines.
540
541 --full-history without parent rewriting
542 This mode differs from the default in one point: always follow all
543 parents of a merge, even if it is TREESAME to one of them. Even if
544 more than one side of the merge has commits that are included, this
545 does not imply that the merge itself is! In the example, we get
546
547 I A B N D O P Q
548
549 M was excluded because it is TREESAME to both parents. E, C and B
550 were all walked, but only B was !TREESAME, so the others do not
551 appear.
552
553 Note that without parent rewriting, it is not really possible to
554 talk about the parent/child relationships between the commits, so
555 we show them disconnected.
556
557 --full-history with parent rewriting
558 Ordinary commits are only included if they are !TREESAME (though
559 this can be changed, see --sparse below).
560
561 Merges are always included. However, their parent list is
562 rewritten: Along each parent, prune away commits that are not
563 included themselves. This results in
564
565 .-A---M---N---O---P---Q
566 / / / / /
567 I B / D /
568 \ / / / /
569 `-------------'
570
571 Compare to --full-history without rewriting above. Note that E was
572 pruned away because it is TREESAME, but the parent list of P was
573 rewritten to contain E's parent I. The same happened for C and N,
574 and X, Y and Q.
575
576 In addition to the above settings, you can change whether TREESAME
577 affects inclusion:
578
579 --dense
580 Commits that are walked are included if they are not TREESAME to
581 any parent.
582
583 --sparse
584 All commits that are walked are included.
585
586 Note that without --full-history, this still simplifies merges: if
587 one of the parents is TREESAME, we follow only that one, so the
588 other sides of the merge are never walked.
589
590 --simplify-merges
591 First, build a history graph in the same way that --full-history
592 with parent rewriting does (see above).
593
594 Then simplify each commit C to its replacement C' in the final
595 history according to the following rules:
596
597 • Set C' to C.
598
599 • Replace each parent P of C' with its simplification P'. In the
600 process, drop parents that are ancestors of other parents or
601 that are root commits TREESAME to an empty tree, and remove
602 duplicates, but take care to never drop all parents that we are
603 TREESAME to.
604
605 • If after this parent rewriting, C' is a root or merge commit
606 (has zero or >1 parents), a boundary commit, or !TREESAME, it
607 remains. Otherwise, it is replaced with its only parent.
608
609 The effect of this is best shown by way of comparing to
610 --full-history with parent rewriting. The example turns into:
611
612 .-A---M---N---O
613 / / /
614 I B D
615 \ / /
616 `---------'
617
618 Note the major differences in N, P, and Q over --full-history:
619
620 • N's parent list had I removed, because it is an ancestor of the
621 other parent M. Still, N remained because it is !TREESAME.
622
623 • P's parent list similarly had I removed. P was then removed
624 completely, because it had one parent and is TREESAME.
625
626 • Q's parent list had Y simplified to X. X was then removed,
627 because it was a TREESAME root. Q was then removed completely,
628 because it had one parent and is TREESAME.
629
630 There is another simplification mode available:
631
632 --ancestry-path
633 Limit the displayed commits to those directly on the ancestry chain
634 between the “from” and “to” commits in the given commit range. I.e.
635 only display commits that are ancestor of the “to” commit and
636 descendants of the “from” commit.
637
638 As an example use case, consider the following commit history:
639
640 D---E-------F
641 / \ \
642 B---C---G---H---I---J
643 / \
644 A-------K---------------L--M
645
646 A regular D..M computes the set of commits that are ancestors of M,
647 but excludes the ones that are ancestors of D. This is useful to
648 see what happened to the history leading to M since D, in the sense
649 that “what does M have that did not exist in D”. The result in this
650 example would be all the commits, except A and B (and D itself, of
651 course).
652
653 When we want to find out what commits in M are contaminated with
654 the bug introduced by D and need fixing, however, we might want to
655 view only the subset of D..M that are actually descendants of D,
656 i.e. excluding C and K. This is exactly what the --ancestry-path
657 option does. Applied to the D..M range, it results in:
658
659 E-------F
660 \ \
661 G---H---I---J
662 \
663 L--M
664
665 Before discussing another option, --show-pulls, we need to create a new
666 example history.
667
668 A common problem users face when looking at simplified history is that
669 a commit they know changed a file somehow does not appear in the file’s
670 simplified history. Let’s demonstrate a new example and show how
671 options such as --full-history and --simplify-merges works in that
672 case:
673
674 .-A---M-----C--N---O---P
675 / / \ \ \/ / /
676 I B \ R-'`-Z' /
677 \ / \/ /
678 \ / /\ /
679 `---X--' `---Y--'
680
681 For this example, suppose I created file.txt which was modified by A,
682 B, and X in different ways. The single-parent commits C, Z, and Y do
683 not change file.txt. The merge commit M was created by resolving the
684 merge conflict to include both changes from A and B and hence is not
685 TREESAME to either. The merge commit R, however, was created by
686 ignoring the contents of file.txt at M and taking only the contents of
687 file.txt at X. Hence, R is TREESAME to X but not M. Finally, the
688 natural merge resolution to create N is to take the contents of
689 file.txt at R, so N is TREESAME to R but not C. The merge commits O and
690 P are TREESAME to their first parents, but not to their second parents,
691 Z and Y respectively.
692
693 When using the default mode, N and R both have a TREESAME parent, so
694 those edges are walked and the others are ignored. The resulting
695 history graph is:
696
697 I---X
698
699 When using --full-history, Git walks every edge. This will discover the
700 commits A and B and the merge M, but also will reveal the merge commits
701 O and P. With parent rewriting, the resulting graph is:
702
703 .-A---M--------N---O---P
704 / / \ \ \/ / /
705 I B \ R-'`--' /
706 \ / \/ /
707 \ / /\ /
708 `---X--' `------'
709
710 Here, the merge commits O and P contribute extra noise, as they did not
711 actually contribute a change to file.txt. They only merged a topic that
712 was based on an older version of file.txt. This is a common issue in
713 repositories using a workflow where many contributors work in parallel
714 and merge their topic branches along a single trunk: manu unrelated
715 merges appear in the --full-history results.
716
717 When using the --simplify-merges option, the commits O and P disappear
718 from the results. This is because the rewritten second parents of O and
719 P are reachable from their first parents. Those edges are removed and
720 then the commits look like single-parent commits that are TREESAME to
721 their parent. This also happens to the commit N, resulting in a history
722 view as follows:
723
724 .-A---M--.
725 / / \
726 I B R
727 \ / /
728 \ / /
729 `---X--'
730
731 In this view, we see all of the important single-parent changes from A,
732 B, and X. We also see the carefully-resolved merge M and the
733 not-so-carefully-resolved merge R. This is usually enough information
734 to determine why the commits A and B "disappeared" from history in the
735 default view. However, there are a few issues with this approach.
736
737 The first issue is performance. Unlike any previous option, the
738 --simplify-merges option requires walking the entire commit history
739 before returning a single result. This can make the option difficult to
740 use for very large repositories.
741
742 The second issue is one of auditing. When many contributors are working
743 on the same repository, it is important which merge commits introduced
744 a change into an important branch. The problematic merge R above is not
745 likely to be the merge commit that was used to merge into an important
746 branch. Instead, the merge N was used to merge R and X into the
747 important branch. This commit may have information about why the change
748 X came to override the changes from A and B in its commit message.
749
750 --show-pulls
751 In addition to the commits shown in the default history, show each
752 merge commit that is not TREESAME to its first parent but is
753 TREESAME to a later parent.
754
755 When a merge commit is included by --show-pulls, the merge is
756 treated as if it "pulled" the change from another branch. When
757 using --show-pulls on this example (and no other options) the
758 resulting graph is:
759
760 I---X---R---N
761
762 Here, the merge commits R and N are included because they pulled
763 the commits X and R into the base branch, respectively. These
764 merges are the reason the commits A and B do not appear in the
765 default history.
766
767 When --show-pulls is paired with --simplify-merges, the graph
768 includes all of the necessary information:
769
770 .-A---M--. N
771 / / \ /
772 I B R
773 \ / /
774 \ / /
775 `---X--'
776
777 Notice that since M is reachable from R, the edge from N to M was
778 simplified away. However, N still appears in the history as an
779 important commit because it "pulled" the change R into the main
780 branch.
781
782 The --simplify-by-decoration option allows you to view only the big
783 picture of the topology of the history, by omitting commits that are
784 not referenced by tags. Commits are marked as !TREESAME (in other
785 words, kept after history simplification rules described above) if (1)
786 they are referenced by tags, or (2) they change the contents of the
787 paths given on the command line. All other commits are marked as
788 TREESAME (subject to be simplified away).
789
790 Commit Ordering
791 By default, the commits are shown in reverse chronological order.
792
793 --date-order
794 Show no parents before all of its children are shown, but otherwise
795 show commits in the commit timestamp order.
796
797 --author-date-order
798 Show no parents before all of its children are shown, but otherwise
799 show commits in the author timestamp order.
800
801 --topo-order
802 Show no parents before all of its children are shown, and avoid
803 showing commits on multiple lines of history intermixed.
804
805 For example, in a commit history like this:
806
807 ---1----2----4----7
808 \ \
809 3----5----6----8---
810
811 where the numbers denote the order of commit timestamps, git
812 rev-list and friends with --date-order show the commits in the
813 timestamp order: 8 7 6 5 4 3 2 1.
814
815 With --topo-order, they would show 8 6 5 3 7 4 2 1 (or 8 7 4 2 6 5
816 3 1); some older commits are shown before newer ones in order to
817 avoid showing the commits from two parallel development track mixed
818 together.
819
820 --reverse
821 Output the commits chosen to be shown (see Commit Limiting section
822 above) in reverse order. Cannot be combined with --walk-reflogs.
823
824 Object Traversal
825 These options are mostly targeted for packing of Git repositories.
826
827 --no-walk[=(sorted|unsorted)]
828 Only show the given commits, but do not traverse their ancestors.
829 This has no effect if a range is specified. If the argument
830 unsorted is given, the commits are shown in the order they were
831 given on the command line. Otherwise (if sorted or no argument was
832 given), the commits are shown in reverse chronological order by
833 commit time. Cannot be combined with --graph.
834
835 --do-walk
836 Overrides a previous --no-walk.
837
838 Commit Formatting
839 --pretty[=<format>], --format=<format>
840 Pretty-print the contents of the commit logs in a given format,
841 where <format> can be one of oneline, short, medium, full, fuller,
842 reference, email, raw, format:<string> and tformat:<string>. When
843 <format> is none of the above, and has %placeholder in it, it acts
844 as if --pretty=tformat:<format> were given.
845
846 See the "PRETTY FORMATS" section for some additional details for
847 each format. When =<format> part is omitted, it defaults to medium.
848
849 Note: you can specify the default pretty format in the repository
850 configuration (see git-config(1)).
851
852 --abbrev-commit
853 Instead of showing the full 40-byte hexadecimal commit object name,
854 show a prefix that names the object uniquely. "--abbrev=<n>" (which
855 also modifies diff output, if it is displayed) option can be used
856 to specify the minimum length of the prefix.
857
858 This should make "--pretty=oneline" a whole lot more readable for
859 people using 80-column terminals.
860
861 --no-abbrev-commit
862 Show the full 40-byte hexadecimal commit object name. This negates
863 --abbrev-commit, either explicit or implied by other options such
864 as "--oneline". It also overrides the log.abbrevCommit variable.
865
866 --oneline
867 This is a shorthand for "--pretty=oneline --abbrev-commit" used
868 together.
869
870 --encoding=<encoding>
871 The commit objects record the encoding used for the log message in
872 their encoding header; this option can be used to tell the command
873 to re-code the commit log message in the encoding preferred by the
874 user. For non plumbing commands this defaults to UTF-8. Note that
875 if an object claims to be encoded in X and we are outputting in X,
876 we will output the object verbatim; this means that invalid
877 sequences in the original commit may be copied to the output.
878
879 --expand-tabs=<n>, --expand-tabs, --no-expand-tabs
880 Perform a tab expansion (replace each tab with enough spaces to
881 fill to the next display column that is multiple of <n>) in the log
882 message before showing it in the output. --expand-tabs is a
883 short-hand for --expand-tabs=8, and --no-expand-tabs is a
884 short-hand for --expand-tabs=0, which disables tab expansion.
885
886 By default, tabs are expanded in pretty formats that indent the log
887 message by 4 spaces (i.e. medium, which is the default, full, and
888 fuller).
889
890 --notes[=<ref>]
891 Show the notes (see git-notes(1)) that annotate the commit, when
892 showing the commit log message. This is the default for git log,
893 git show and git whatchanged commands when there is no --pretty,
894 --format, or --oneline option given on the command line.
895
896 By default, the notes shown are from the notes refs listed in the
897 core.notesRef and notes.displayRef variables (or corresponding
898 environment overrides). See git-config(1) for more details.
899
900 With an optional <ref> argument, use the ref to find the notes to
901 display. The ref can specify the full refname when it begins with
902 refs/notes/; when it begins with notes/, refs/ and otherwise
903 refs/notes/ is prefixed to form a full name of the ref.
904
905 Multiple --notes options can be combined to control which notes are
906 being displayed. Examples: "--notes=foo" will show only notes from
907 "refs/notes/foo"; "--notes=foo --notes" will show both notes from
908 "refs/notes/foo" and from the default notes ref(s).
909
910 --no-notes
911 Do not show notes. This negates the above --notes option, by
912 resetting the list of notes refs from which notes are shown.
913 Options are parsed in the order given on the command line, so e.g.
914 "--notes --notes=foo --no-notes --notes=bar" will only show notes
915 from "refs/notes/bar".
916
917 --show-notes[=<ref>], --[no-]standard-notes
918 These options are deprecated. Use the above --notes/--no-notes
919 options instead.
920
921 --show-signature
922 Check the validity of a signed commit object by passing the
923 signature to gpg --verify and show the output.
924
925 --relative-date
926 Synonym for --date=relative.
927
928 --date=<format>
929 Only takes effect for dates shown in human-readable format, such as
930 when using --pretty. log.date config variable sets a default value
931 for the log command’s --date option. By default, dates are shown in
932 the original time zone (either committer’s or author’s). If -local
933 is appended to the format (e.g., iso-local), the user’s local time
934 zone is used instead.
935
936 --date=relative shows dates relative to the current time, e.g. “2
937 hours ago”. The -local option has no effect for --date=relative.
938
939 --date=local is an alias for --date=default-local.
940
941 --date=iso (or --date=iso8601) shows timestamps in a ISO 8601-like
942 format. The differences to the strict ISO 8601 format are:
943
944 • a space instead of the T date/time delimiter
945
946 • a space between time and time zone
947
948 • no colon between hours and minutes of the time zone
949
950 --date=iso-strict (or --date=iso8601-strict) shows timestamps in
951 strict ISO 8601 format.
952
953 --date=rfc (or --date=rfc2822) shows timestamps in RFC 2822 format,
954 often found in email messages.
955
956 --date=short shows only the date, but not the time, in YYYY-MM-DD
957 format.
958
959 --date=raw shows the date as seconds since the epoch (1970-01-01
960 00:00:00 UTC), followed by a space, and then the timezone as an
961 offset from UTC (a + or - with four digits; the first two are
962 hours, and the second two are minutes). I.e., as if the timestamp
963 were formatted with strftime("%s %z")). Note that the -local option
964 does not affect the seconds-since-epoch value (which is always
965 measured in UTC), but does switch the accompanying timezone value.
966
967 --date=human shows the timezone if the timezone does not match the
968 current time-zone, and doesn’t print the whole date if that matches
969 (ie skip printing year for dates that are "this year", but also
970 skip the whole date itself if it’s in the last few days and we can
971 just say what weekday it was). For older dates the hour and minute
972 is also omitted.
973
974 --date=unix shows the date as a Unix epoch timestamp (seconds since
975 1970). As with --raw, this is always in UTC and therefore -local
976 has no effect.
977
978 --date=format:... feeds the format ... to your system strftime,
979 except for %z and %Z, which are handled internally. Use
980 --date=format:%c to show the date in your system locale’s preferred
981 format. See the strftime manual for a complete list of format
982 placeholders. When using -local, the correct syntax is
983 --date=format-local:....
984
985 --date=default is the default format, and is similar to
986 --date=rfc2822, with a few exceptions:
987
988 • there is no comma after the day-of-week
989
990 • the time zone is omitted when the local time zone is used
991
992 --parents
993 Print also the parents of the commit (in the form "commit parent...
994 "). Also enables parent rewriting, see History Simplification
995 above.
996
997 --children
998 Print also the children of the commit (in the form "commit child...
999 "). Also enables parent rewriting, see History Simplification
1000 above.
1001
1002 --left-right
1003 Mark which side of a symmetric difference a commit is reachable
1004 from. Commits from the left side are prefixed with < and those from
1005 the right with >. If combined with --boundary, those commits are
1006 prefixed with -.
1007
1008 For example, if you have this topology:
1009
1010 y---b---b branch B
1011 / \ /
1012 / .
1013 / / \
1014 o---x---a---a branch A
1015
1016 you would get an output like this:
1017
1018 $ git rev-list --left-right --boundary --pretty=oneline A...B
1019
1020 >bbbbbbb... 3rd on b
1021 >bbbbbbb... 2nd on b
1022 <aaaaaaa... 3rd on a
1023 <aaaaaaa... 2nd on a
1024 -yyyyyyy... 1st on b
1025 -xxxxxxx... 1st on a
1026
1027 --graph
1028 Draw a text-based graphical representation of the commit history on
1029 the left hand side of the output. This may cause extra lines to be
1030 printed in between commits, in order for the graph history to be
1031 drawn properly. Cannot be combined with --no-walk.
1032
1033 This enables parent rewriting, see History Simplification above.
1034
1035 This implies the --topo-order option by default, but the
1036 --date-order option may also be specified.
1037
1038 --show-linear-break[=<barrier>]
1039 When --graph is not used, all history branches are flattened which
1040 can make it hard to see that the two consecutive commits do not
1041 belong to a linear branch. This option puts a barrier in between
1042 them in that case. If <barrier> is specified, it is the string that
1043 will be shown instead of the default one.
1044
1046 If the commit is a merge, and if the pretty-format is not oneline,
1047 email or raw, an additional line is inserted before the Author: line.
1048 This line begins with "Merge: " and the hashes of ancestral commits are
1049 printed, separated by spaces. Note that the listed commits may not
1050 necessarily be the list of the direct parent commits if you have
1051 limited your view of history: for example, if you are only interested
1052 in changes related to a certain directory or file.
1053
1054 There are several built-in formats, and you can define additional
1055 formats by setting a pretty.<name> config option to either another
1056 format name, or a format: string, as described below (see git-
1057 config(1)). Here are the details of the built-in formats:
1058
1059 • oneline
1060
1061 <hash> <title line>
1062
1063 This is designed to be as compact as possible.
1064
1065 • short
1066
1067 commit <hash>
1068 Author: <author>
1069
1070 <title line>
1071
1072 • medium
1073
1074 commit <hash>
1075 Author: <author>
1076 Date: <author date>
1077
1078 <title line>
1079
1080 <full commit message>
1081
1082 • full
1083
1084 commit <hash>
1085 Author: <author>
1086 Commit: <committer>
1087
1088 <title line>
1089
1090 <full commit message>
1091
1092 • fuller
1093
1094 commit <hash>
1095 Author: <author>
1096 AuthorDate: <author date>
1097 Commit: <committer>
1098 CommitDate: <committer date>
1099
1100 <title line>
1101
1102 <full commit message>
1103
1104 • reference
1105
1106 <abbrev hash> (<title line>, <short author date>)
1107
1108 This format is used to refer to another commit in a commit message
1109 and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By
1110 default, the date is formatted with --date=short unless another
1111 --date option is explicitly specified. As with any format: with
1112 format placeholders, its output is not affected by other options
1113 like --decorate and --walk-reflogs.
1114
1115 • email
1116
1117 From <hash> <date>
1118 From: <author>
1119 Date: <author date>
1120 Subject: [PATCH] <title line>
1121
1122 <full commit message>
1123
1124 • mboxrd
1125
1126 Like email, but lines in the commit message starting with "From "
1127 (preceded by zero or more ">") are quoted with ">" so they aren’t
1128 confused as starting a new commit.
1129
1130 • raw
1131
1132 The raw format shows the entire commit exactly as stored in the
1133 commit object. Notably, the hashes are displayed in full,
1134 regardless of whether --abbrev or --no-abbrev are used, and parents
1135 information show the true parent commits, without taking grafts or
1136 history simplification into account. Note that this format affects
1137 the way commits are displayed, but not the way the diff is shown
1138 e.g. with git log --raw. To get full object names in a raw diff
1139 format, use --no-abbrev.
1140
1141 • format:<string>
1142
1143 The format:<string> format allows you to specify which information
1144 you want to show. It works a little bit like printf format, with
1145 the notable exception that you get a newline with %n instead of \n.
1146
1147 E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
1148 would show something like this:
1149
1150 The author of fe6e0ee was Junio C Hamano, 23 hours ago
1151 The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<
1152
1153 The placeholders are:
1154
1155 • Placeholders that expand to a single literal character:
1156
1157 %n
1158 newline
1159
1160 %%
1161 a raw %
1162
1163 %x00
1164 print a byte from a hex code
1165
1166 • Placeholders that affect formatting of later placeholders:
1167
1168 %Cred
1169 switch color to red
1170
1171 %Cgreen
1172 switch color to green
1173
1174 %Cblue
1175 switch color to blue
1176
1177 %Creset
1178 reset color
1179
1180 %C(...)
1181 color specification, as described under Values in the
1182 "CONFIGURATION FILE" section of git-config(1). By default,
1183 colors are shown only when enabled for log output (by
1184 color.diff, color.ui, or --color, and respecting the auto
1185 settings of the former if we are going to a terminal).
1186 %C(auto,...) is accepted as a historical synonym for the
1187 default (e.g., %C(auto,red)). Specifying %C(always,...)
1188 will show the colors even when color is not otherwise
1189 enabled (though consider just using --color=always to
1190 enable color for the whole output, including this format
1191 and anything else git might color). auto alone (i.e.
1192 %C(auto)) will turn on auto coloring on the next
1193 placeholders until the color is switched again.
1194
1195 %m
1196 left (<), right (>) or boundary (-) mark
1197
1198 %w([<w>[,<i1>[,<i2>]]])
1199 switch line wrapping, like the -w option of git-
1200 shortlog(1).
1201
1202 %<(<N>[,trunc|ltrunc|mtrunc])
1203 make the next placeholder take at least N columns, padding
1204 spaces on the right if necessary. Optionally truncate at
1205 the beginning (ltrunc), the middle (mtrunc) or the end
1206 (trunc) if the output is longer than N columns. Note that
1207 truncating only works correctly with N >= 2.
1208
1209 %<|(<N>)
1210 make the next placeholder take at least until Nth columns,
1211 padding spaces on the right if necessary
1212
1213 %>(<N>), %>|(<N>)
1214 similar to %<(<N>), %<|(<N>) respectively, but padding
1215 spaces on the left
1216
1217 %>>(<N>), %>>|(<N>)
1218 similar to %>(<N>), %>|(<N>) respectively, except that if
1219 the next placeholder takes more spaces than given and there
1220 are spaces on its left, use those spaces
1221
1222 %><(<N>), %><|(<N>)
1223 similar to %<(<N>), %<|(<N>) respectively, but padding both
1224 sides (i.e. the text is centered)
1225
1226 • Placeholders that expand to information extracted from the
1227 commit:
1228
1229 %H
1230 commit hash
1231
1232 %h
1233 abbreviated commit hash
1234
1235 %T
1236 tree hash
1237
1238 %t
1239 abbreviated tree hash
1240
1241 %P
1242 parent hashes
1243
1244 %p
1245 abbreviated parent hashes
1246
1247 %an
1248 author name
1249
1250 %aN
1251 author name (respecting .mailmap, see git-shortlog(1) or
1252 git-blame(1))
1253
1254 %ae
1255 author email
1256
1257 %aE
1258 author email (respecting .mailmap, see git-shortlog(1) or
1259 git-blame(1))
1260
1261 %al
1262 author email local-part (the part before the @ sign)
1263
1264 %aL
1265 author local-part (see %al) respecting .mailmap, see git-
1266 shortlog(1) or git-blame(1))
1267
1268 %ad
1269 author date (format respects --date= option)
1270
1271 %aD
1272 author date, RFC2822 style
1273
1274 %ar
1275 author date, relative
1276
1277 %at
1278 author date, UNIX timestamp
1279
1280 %ai
1281 author date, ISO 8601-like format
1282
1283 %aI
1284 author date, strict ISO 8601 format
1285
1286 %as
1287 author date, short format (YYYY-MM-DD)
1288
1289 %cn
1290 committer name
1291
1292 %cN
1293 committer name (respecting .mailmap, see git-shortlog(1) or
1294 git-blame(1))
1295
1296 %ce
1297 committer email
1298
1299 %cE
1300 committer email (respecting .mailmap, see git-shortlog(1)
1301 or git-blame(1))
1302
1303 %cl
1304 committer email local-part (the part before the @ sign)
1305
1306 %cL
1307 committer local-part (see %cl) respecting .mailmap, see
1308 git-shortlog(1) or git-blame(1))
1309
1310 %cd
1311 committer date (format respects --date= option)
1312
1313 %cD
1314 committer date, RFC2822 style
1315
1316 %cr
1317 committer date, relative
1318
1319 %ct
1320 committer date, UNIX timestamp
1321
1322 %ci
1323 committer date, ISO 8601-like format
1324
1325 %cI
1326 committer date, strict ISO 8601 format
1327
1328 %cs
1329 committer date, short format (YYYY-MM-DD)
1330
1331 %d
1332 ref names, like the --decorate option of git-log(1)
1333
1334 %D
1335 ref names without the " (", ")" wrapping.
1336
1337 %S
1338 ref name given on the command line by which the commit was
1339 reached (like git log --source), only works with git log
1340
1341 %e
1342 encoding
1343
1344 %s
1345 subject
1346
1347 %f
1348 sanitized subject line, suitable for a filename
1349
1350 %b
1351 body
1352
1353 %B
1354 raw body (unwrapped subject and body)
1355
1356 %N
1357 commit notes
1358
1359 %GG
1360 raw verification message from GPG for a signed commit
1361
1362 %G?
1363 show "G" for a good (valid) signature, "B" for a bad
1364 signature, "U" for a good signature with unknown validity,
1365 "X" for a good signature that has expired, "Y" for a good
1366 signature made by an expired key, "R" for a good signature
1367 made by a revoked key, "E" if the signature cannot be
1368 checked (e.g. missing key) and "N" for no signature
1369
1370 %GS
1371 show the name of the signer for a signed commit
1372
1373 %GK
1374 show the key used to sign a signed commit
1375
1376 %GF
1377 show the fingerprint of the key used to sign a signed
1378 commit
1379
1380 %GP
1381 show the fingerprint of the primary key whose subkey was
1382 used to sign a signed commit
1383
1384 %GT
1385 show the trust level for the key used to sign a signed
1386 commit
1387
1388 %gD
1389 reflog selector, e.g., refs/stash@{1} or refs/stash@{2
1390 minutes ago}; the format follows the rules described for
1391 the -g option. The portion before the @ is the refname as
1392 given on the command line (so git log -g refs/heads/master
1393 would yield refs/heads/master@{0}).
1394
1395 %gd
1396 shortened reflog selector; same as %gD, but the refname
1397 portion is shortened for human readability (so
1398 refs/heads/master becomes just master).
1399
1400 %gn
1401 reflog identity name
1402
1403 %gN
1404 reflog identity name (respecting .mailmap, see git-
1405 shortlog(1) or git-blame(1))
1406
1407 %ge
1408 reflog identity email
1409
1410 %gE
1411 reflog identity email (respecting .mailmap, see git-
1412 shortlog(1) or git-blame(1))
1413
1414 %gs
1415 reflog subject
1416
1417 %(trailers[:options])
1418 display the trailers of the body as interpreted by git-
1419 interpret-trailers(1). The trailers string may be followed
1420 by a colon and zero or more comma-separated options. If any
1421 option is provided multiple times the last occurance wins.
1422
1423 The boolean options accept an optional value [=<BOOL>]. The
1424 values true, false, on, off etc. are all accepted. See the
1425 "boolean" sub-section in "EXAMPLES" in git-config(1). If a
1426 boolean option is given with no value, it’s enabled.
1427
1428 • key=<K>: only show trailers with specified key.
1429 Matching is done case-insensitively and trailing colon
1430 is optional. If option is given multiple times trailer
1431 lines matching any of the keys are shown. This option
1432 automatically enables the only option so that
1433 non-trailer lines in the trailer block are hidden. If
1434 that is not desired it can be disabled with only=false.
1435 E.g., %(trailers:key=Reviewed-by) shows trailer lines
1436 with key Reviewed-by.
1437
1438 • only[=<BOOL>]: select whether non-trailer lines from
1439 the trailer block should be included.
1440
1441 • separator=<SEP>: specify a separator inserted between
1442 trailer lines. When this option is not given each
1443 trailer line is terminated with a line feed character.
1444 The string SEP may contain the literal formatting codes
1445 described above. To use comma as separator one must use
1446 %x2C as it would otherwise be parsed as next option.
1447 E.g., %(trailers:key=Ticket,separator=%x2C ) shows all
1448 trailer lines whose key is "Ticket" separated by a
1449 comma and a space.
1450
1451 • unfold[=<BOOL>]: make it behave as if
1452 interpret-trailer’s --unfold option was given. E.g.,
1453 %(trailers:only,unfold=true) unfolds and shows all
1454 trailer lines.
1455
1456 • keyonly[=<BOOL>]: only show the key part of the
1457 trailer.
1458
1459 • valueonly[=<BOOL>]: only show the value part of the
1460 trailer.
1461
1462 • key_value_separator=<SEP>: specify a separator inserted
1463 between trailer lines. When this option is not given
1464 each trailer key-value pair is separated by ": ".
1465 Otherwise it shares the same semantics as
1466 separator=<SEP> above.
1467
1468 Note
1469 Some placeholders may depend on other options given to the revision
1470 traversal engine. For example, the %g* reflog options will insert
1471 an empty string unless we are traversing reflog entries (e.g., by
1472 git log -g). The %d and %D placeholders will use the "short"
1473 decoration format if --decorate was not already provided on the
1474 command line.
1475
1476 If you add a + (plus sign) after % of a placeholder, a line-feed is
1477 inserted immediately before the expansion if and only if the
1478 placeholder expands to a non-empty string.
1479
1480 If you add a - (minus sign) after % of a placeholder, all consecutive
1481 line-feeds immediately preceding the expansion are deleted if and only
1482 if the placeholder expands to an empty string.
1483
1484 If you add a ` ` (space) after % of a placeholder, a space is inserted
1485 immediately before the expansion if and only if the placeholder expands
1486 to a non-empty string.
1487
1488 • tformat:
1489
1490 The tformat: format works exactly like format:, except that it
1491 provides "terminator" semantics instead of "separator" semantics.
1492 In other words, each commit has the message terminator character
1493 (usually a newline) appended, rather than a separator placed
1494 between entries. This means that the final entry of a single-line
1495 format will be properly terminated with a new line, just as the
1496 "oneline" format does. For example:
1497
1498 $ git log -2 --pretty=format:%h 4da45bef \
1499 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1500 4da45be
1501 7134973 -- NO NEWLINE
1502
1503 $ git log -2 --pretty=tformat:%h 4da45bef \
1504 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1505 4da45be
1506 7134973
1507
1508 In addition, any unrecognized string that has a % in it is
1509 interpreted as if it has tformat: in front of it. For example,
1510 these two are equivalent:
1511
1512 $ git log -2 --pretty=tformat:%h 4da45bef
1513 $ git log -2 --pretty=%h 4da45bef
1514
1516 By default, git log does not generate any diff output. The options
1517 below can be used to show the changes made by each commit.
1518
1519 Note that unless one of --diff-merges variants (including short -m, -c,
1520 and --cc options) is explicitly given, merge commits will not show a
1521 diff, even if a diff format like --patch is selected, nor will they
1522 match search options like -S. The exception is when --first-parent is
1523 in use, in which case first-parent is the default format.
1524
1525 -p, -u, --patch
1526 Generate patch (see section on generating patches).
1527
1528 -s, --no-patch
1529 Suppress diff output. Useful for commands like git show that show
1530 the patch by default, or to cancel the effect of --patch.
1531
1532 --diff-merges=(off|none|first-parent|1|separate|m|combined|c|dense-combined|cc),
1533 --no-diff-merges
1534 Specify diff format to be used for merge commits. Default is `off`
1535 unless --first-parent is in use, in which case first-parent is the
1536 default.
1537
1538 --diff-merges=(off|none), --no-diff-merges
1539 Disable output of diffs for merge commits. Useful to override
1540 implied value.
1541
1542 --diff-merges=first-parent, --diff-merges=1
1543 This option makes merge commits show the full diff with respect
1544 to the first parent only.
1545
1546 --diff-merges=separate, --diff-merges=m, -m
1547 This makes merge commits show the full diff with respect to
1548 each of the parents. Separate log entry and diff is generated
1549 for each parent. -m doesn’t produce any output without -p.
1550
1551 --diff-merges=combined, --diff-merges=c, -c
1552 With this option, diff output for a merge commit shows the
1553 differences from each of the parents to the merge result
1554 simultaneously instead of showing pairwise diff between a
1555 parent and the result one at a time. Furthermore, it lists only
1556 files which were modified from all parents. -c implies -p.
1557
1558 --diff-merges=dense-combined, --diff-merges=cc, --cc
1559 With this option the output produced by --diff-merges=combined
1560 is further compressed by omitting uninteresting hunks whose
1561 contents in the parents have only two variants and the merge
1562 result picks one of them without modification. --cc implies
1563 -p.
1564
1565 --combined-all-paths
1566 This flag causes combined diffs (used for merge commits) to list
1567 the name of the file from all parents. It thus only has effect when
1568 --diff-merges=[dense-]combined is in use, and is likely only useful
1569 if filename changes are detected (i.e. when either rename or copy
1570 detection have been requested).
1571
1572 -U<n>, --unified=<n>
1573 Generate diffs with <n> lines of context instead of the usual
1574 three. Implies --patch.
1575
1576 --output=<file>
1577 Output to a specific file instead of stdout.
1578
1579 --output-indicator-new=<char>, --output-indicator-old=<char>,
1580 --output-indicator-context=<char>
1581 Specify the character used to indicate new, old or context lines in
1582 the generated patch. Normally they are +, - and ' ' respectively.
1583
1584 --raw
1585 For each commit, show a summary of changes using the raw diff
1586 format. See the "RAW OUTPUT FORMAT" section of git-diff(1). This is
1587 different from showing the log itself in raw format, which you can
1588 achieve with --format=raw.
1589
1590 --patch-with-raw
1591 Synonym for -p --raw.
1592
1593 -t
1594 Show the tree objects in the diff output.
1595
1596 --indent-heuristic
1597 Enable the heuristic that shifts diff hunk boundaries to make
1598 patches easier to read. This is the default.
1599
1600 --no-indent-heuristic
1601 Disable the indent heuristic.
1602
1603 --minimal
1604 Spend extra time to make sure the smallest possible diff is
1605 produced.
1606
1607 --patience
1608 Generate a diff using the "patience diff" algorithm.
1609
1610 --histogram
1611 Generate a diff using the "histogram diff" algorithm.
1612
1613 --anchored=<text>
1614 Generate a diff using the "anchored diff" algorithm.
1615
1616 This option may be specified more than once.
1617
1618 If a line exists in both the source and destination, exists only
1619 once, and starts with this text, this algorithm attempts to prevent
1620 it from appearing as a deletion or addition in the output. It uses
1621 the "patience diff" algorithm internally.
1622
1623 --diff-algorithm={patience|minimal|histogram|myers}
1624 Choose a diff algorithm. The variants are as follows:
1625
1626 default, myers
1627 The basic greedy diff algorithm. Currently, this is the
1628 default.
1629
1630 minimal
1631 Spend extra time to make sure the smallest possible diff is
1632 produced.
1633
1634 patience
1635 Use "patience diff" algorithm when generating patches.
1636
1637 histogram
1638 This algorithm extends the patience algorithm to "support
1639 low-occurrence common elements".
1640
1641 For instance, if you configured the diff.algorithm variable to a
1642 non-default value and want to use the default one, then you have to
1643 use --diff-algorithm=default option.
1644
1645 --stat[=<width>[,<name-width>[,<count>]]]
1646 Generate a diffstat. By default, as much space as necessary will be
1647 used for the filename part, and the rest for the graph part.
1648 Maximum width defaults to terminal width, or 80 columns if not
1649 connected to a terminal, and can be overridden by <width>. The
1650 width of the filename part can be limited by giving another width
1651 <name-width> after a comma. The width of the graph part can be
1652 limited by using --stat-graph-width=<width> (affects all commands
1653 generating a stat graph) or by setting diff.statGraphWidth=<width>
1654 (does not affect git format-patch). By giving a third parameter
1655 <count>, you can limit the output to the first <count> lines,
1656 followed by ... if there are more.
1657
1658 These parameters can also be set individually with
1659 --stat-width=<width>, --stat-name-width=<name-width> and
1660 --stat-count=<count>.
1661
1662 --compact-summary
1663 Output a condensed summary of extended header information such as
1664 file creations or deletions ("new" or "gone", optionally "+l" if
1665 it’s a symlink) and mode changes ("+x" or "-x" for adding or
1666 removing executable bit respectively) in diffstat. The information
1667 is put between the filename part and the graph part. Implies
1668 --stat.
1669
1670 --numstat
1671 Similar to --stat, but shows number of added and deleted lines in
1672 decimal notation and pathname without abbreviation, to make it more
1673 machine friendly. For binary files, outputs two - instead of saying
1674 0 0.
1675
1676 --shortstat
1677 Output only the last line of the --stat format containing total
1678 number of modified files, as well as number of added and deleted
1679 lines.
1680
1681 -X[<param1,param2,...>], --dirstat[=<param1,param2,...>]
1682 Output the distribution of relative amount of changes for each
1683 sub-directory. The behavior of --dirstat can be customized by
1684 passing it a comma separated list of parameters. The defaults are
1685 controlled by the diff.dirstat configuration variable (see git-
1686 config(1)). The following parameters are available:
1687
1688 changes
1689 Compute the dirstat numbers by counting the lines that have
1690 been removed from the source, or added to the destination. This
1691 ignores the amount of pure code movements within a file. In
1692 other words, rearranging lines in a file is not counted as much
1693 as other changes. This is the default behavior when no
1694 parameter is given.
1695
1696 lines
1697 Compute the dirstat numbers by doing the regular line-based
1698 diff analysis, and summing the removed/added line counts. (For
1699 binary files, count 64-byte chunks instead, since binary files
1700 have no natural concept of lines). This is a more expensive
1701 --dirstat behavior than the changes behavior, but it does count
1702 rearranged lines within a file as much as other changes. The
1703 resulting output is consistent with what you get from the other
1704 --*stat options.
1705
1706 files
1707 Compute the dirstat numbers by counting the number of files
1708 changed. Each changed file counts equally in the dirstat
1709 analysis. This is the computationally cheapest --dirstat
1710 behavior, since it does not have to look at the file contents
1711 at all.
1712
1713 cumulative
1714 Count changes in a child directory for the parent directory as
1715 well. Note that when using cumulative, the sum of the
1716 percentages reported may exceed 100%. The default
1717 (non-cumulative) behavior can be specified with the
1718 noncumulative parameter.
1719
1720 <limit>
1721 An integer parameter specifies a cut-off percent (3% by
1722 default). Directories contributing less than this percentage of
1723 the changes are not shown in the output.
1724
1725 Example: The following will count changed files, while ignoring
1726 directories with less than 10% of the total amount of changed
1727 files, and accumulating child directory counts in the parent
1728 directories: --dirstat=files,10,cumulative.
1729
1730 --cumulative
1731 Synonym for --dirstat=cumulative
1732
1733 --dirstat-by-file[=<param1,param2>...]
1734 Synonym for --dirstat=files,param1,param2...
1735
1736 --summary
1737 Output a condensed summary of extended header information such as
1738 creations, renames and mode changes.
1739
1740 --patch-with-stat
1741 Synonym for -p --stat.
1742
1743 -z
1744 Separate the commits with NULs instead of with new newlines.
1745
1746 Also, when --raw or --numstat has been given, do not munge
1747 pathnames and use NULs as output field terminators.
1748
1749 Without this option, pathnames with "unusual" characters are quoted
1750 as explained for the configuration variable core.quotePath (see
1751 git-config(1)).
1752
1753 --name-only
1754 Show only names of changed files.
1755
1756 --name-status
1757 Show only names and status of changed files. See the description of
1758 the --diff-filter option on what the status letters mean.
1759
1760 --submodule[=<format>]
1761 Specify how differences in submodules are shown. When specifying
1762 --submodule=short the short format is used. This format just shows
1763 the names of the commits at the beginning and end of the range.
1764 When --submodule or --submodule=log is specified, the log format is
1765 used. This format lists the commits in the range like git-
1766 submodule(1) summary does. When --submodule=diff is specified, the
1767 diff format is used. This format shows an inline diff of the
1768 changes in the submodule contents between the commit range.
1769 Defaults to diff.submodule or the short format if the config option
1770 is unset.
1771
1772 --color[=<when>]
1773 Show colored diff. --color (i.e. without =<when>) is the same as
1774 --color=always. <when> can be one of always, never, or auto.
1775
1776 --no-color
1777 Turn off colored diff. It is the same as --color=never.
1778
1779 --color-moved[=<mode>]
1780 Moved lines of code are colored differently. The <mode> defaults to
1781 no if the option is not given and to zebra if the option with no
1782 mode is given. The mode must be one of:
1783
1784 no
1785 Moved lines are not highlighted.
1786
1787 default
1788 Is a synonym for zebra. This may change to a more sensible mode
1789 in the future.
1790
1791 plain
1792 Any line that is added in one location and was removed in
1793 another location will be colored with color.diff.newMoved.
1794 Similarly color.diff.oldMoved will be used for removed lines
1795 that are added somewhere else in the diff. This mode picks up
1796 any moved line, but it is not very useful in a review to
1797 determine if a block of code was moved without permutation.
1798
1799 blocks
1800 Blocks of moved text of at least 20 alphanumeric characters are
1801 detected greedily. The detected blocks are painted using either
1802 the color.diff.{old,new}Moved color. Adjacent blocks cannot be
1803 told apart.
1804
1805 zebra
1806 Blocks of moved text are detected as in blocks mode. The blocks
1807 are painted using either the color.diff.{old,new}Moved color or
1808 color.diff.{old,new}MovedAlternative. The change between the
1809 two colors indicates that a new block was detected.
1810
1811 dimmed-zebra
1812 Similar to zebra, but additional dimming of uninteresting parts
1813 of moved code is performed. The bordering lines of two adjacent
1814 blocks are considered interesting, the rest is uninteresting.
1815 dimmed_zebra is a deprecated synonym.
1816
1817 --no-color-moved
1818 Turn off move detection. This can be used to override configuration
1819 settings. It is the same as --color-moved=no.
1820
1821 --color-moved-ws=<modes>
1822 This configures how whitespace is ignored when performing the move
1823 detection for --color-moved. These modes can be given as a comma
1824 separated list:
1825
1826 no
1827 Do not ignore whitespace when performing move detection.
1828
1829 ignore-space-at-eol
1830 Ignore changes in whitespace at EOL.
1831
1832 ignore-space-change
1833 Ignore changes in amount of whitespace. This ignores whitespace
1834 at line end, and considers all other sequences of one or more
1835 whitespace characters to be equivalent.
1836
1837 ignore-all-space
1838 Ignore whitespace when comparing lines. This ignores
1839 differences even if one line has whitespace where the other
1840 line has none.
1841
1842 allow-indentation-change
1843 Initially ignore any whitespace in the move detection, then
1844 group the moved code blocks only into a block if the change in
1845 whitespace is the same per line. This is incompatible with the
1846 other modes.
1847
1848 --no-color-moved-ws
1849 Do not ignore whitespace when performing move detection. This can
1850 be used to override configuration settings. It is the same as
1851 --color-moved-ws=no.
1852
1853 --word-diff[=<mode>]
1854 Show a word diff, using the <mode> to delimit changed words. By
1855 default, words are delimited by whitespace; see --word-diff-regex
1856 below. The <mode> defaults to plain, and must be one of:
1857
1858 color
1859 Highlight changed words using only colors. Implies --color.
1860
1861 plain
1862 Show words as [-removed-] and {+added+}. Makes no attempts to
1863 escape the delimiters if they appear in the input, so the
1864 output may be ambiguous.
1865
1866 porcelain
1867 Use a special line-based format intended for script
1868 consumption. Added/removed/unchanged runs are printed in the
1869 usual unified diff format, starting with a +/-/` ` character at
1870 the beginning of the line and extending to the end of the line.
1871 Newlines in the input are represented by a tilde ~ on a line of
1872 its own.
1873
1874 none
1875 Disable word diff again.
1876
1877 Note that despite the name of the first mode, color is used to
1878 highlight the changed parts in all modes if enabled.
1879
1880 --word-diff-regex=<regex>
1881 Use <regex> to decide what a word is, instead of considering runs
1882 of non-whitespace to be a word. Also implies --word-diff unless it
1883 was already enabled.
1884
1885 Every non-overlapping match of the <regex> is considered a word.
1886 Anything between these matches is considered whitespace and
1887 ignored(!) for the purposes of finding differences. You may want to
1888 append |[^[:space:]] to your regular expression to make sure that
1889 it matches all non-whitespace characters. A match that contains a
1890 newline is silently truncated(!) at the newline.
1891
1892 For example, --word-diff-regex=. will treat each character as a
1893 word and, correspondingly, show differences character by character.
1894
1895 The regex can also be set via a diff driver or configuration
1896 option, see gitattributes(5) or git-config(1). Giving it explicitly
1897 overrides any diff driver or configuration setting. Diff drivers
1898 override configuration settings.
1899
1900 --color-words[=<regex>]
1901 Equivalent to --word-diff=color plus (if a regex was specified)
1902 --word-diff-regex=<regex>.
1903
1904 --no-renames
1905 Turn off rename detection, even when the configuration file gives
1906 the default to do so.
1907
1908 --[no-]rename-empty
1909 Whether to use empty blobs as rename source.
1910
1911 --check
1912 Warn if changes introduce conflict markers or whitespace errors.
1913 What are considered whitespace errors is controlled by
1914 core.whitespace configuration. By default, trailing whitespaces
1915 (including lines that consist solely of whitespaces) and a space
1916 character that is immediately followed by a tab character inside
1917 the initial indent of the line are considered whitespace errors.
1918 Exits with non-zero status if problems are found. Not compatible
1919 with --exit-code.
1920
1921 --ws-error-highlight=<kind>
1922 Highlight whitespace errors in the context, old or new lines of the
1923 diff. Multiple values are separated by comma, none resets previous
1924 values, default reset the list to new and all is a shorthand for
1925 old,new,context. When this option is not given, and the
1926 configuration variable diff.wsErrorHighlight is not set, only
1927 whitespace errors in new lines are highlighted. The whitespace
1928 errors are colored with color.diff.whitespace.
1929
1930 --full-index
1931 Instead of the first handful of characters, show the full pre- and
1932 post-image blob object names on the "index" line when generating
1933 patch format output.
1934
1935 --binary
1936 In addition to --full-index, output a binary diff that can be
1937 applied with git-apply. Implies --patch.
1938
1939 --abbrev[=<n>]
1940 Instead of showing the full 40-byte hexadecimal object name in
1941 diff-raw format output and diff-tree header lines, show the
1942 shortest prefix that is at least <n> hexdigits long that uniquely
1943 refers the object. In diff-patch output format, --full-index takes
1944 higher precedence, i.e. if --full-index is specified, full blob
1945 names will be shown regardless of --abbrev. Non default number of
1946 digits can be specified with --abbrev=<n>.
1947
1948 -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]]
1949 Break complete rewrite changes into pairs of delete and create.
1950 This serves two purposes:
1951
1952 It affects the way a change that amounts to a total rewrite of a
1953 file not as a series of deletion and insertion mixed together with
1954 a very few lines that happen to match textually as the context, but
1955 as a single deletion of everything old followed by a single
1956 insertion of everything new, and the number m controls this aspect
1957 of the -B option (defaults to 60%). -B/70% specifies that less
1958 than 30% of the original should remain in the result for Git to
1959 consider it a total rewrite (i.e. otherwise the resulting patch
1960 will be a series of deletion and insertion mixed together with
1961 context lines).
1962
1963 When used with -M, a totally-rewritten file is also considered as
1964 the source of a rename (usually -M only considers a file that
1965 disappeared as the source of a rename), and the number n controls
1966 this aspect of the -B option (defaults to 50%). -B20% specifies
1967 that a change with addition and deletion compared to 20% or more of
1968 the file’s size are eligible for being picked up as a possible
1969 source of a rename to another file.
1970
1971 -M[<n>], --find-renames[=<n>]
1972 If generating diffs, detect and report renames for each commit. For
1973 following files across renames while traversing history, see
1974 --follow. If n is specified, it is a threshold on the similarity
1975 index (i.e. amount of addition/deletions compared to the file’s
1976 size). For example, -M90% means Git should consider a delete/add
1977 pair to be a rename if more than 90% of the file hasn’t changed.
1978 Without a % sign, the number is to be read as a fraction, with a
1979 decimal point before it. I.e., -M5 becomes 0.5, and is thus the
1980 same as -M50%. Similarly, -M05 is the same as -M5%. To limit
1981 detection to exact renames, use -M100%. The default similarity
1982 index is 50%.
1983
1984 -C[<n>], --find-copies[=<n>]
1985 Detect copies as well as renames. See also --find-copies-harder. If
1986 n is specified, it has the same meaning as for -M<n>.
1987
1988 --find-copies-harder
1989 For performance reasons, by default, -C option finds copies only if
1990 the original file of the copy was modified in the same changeset.
1991 This flag makes the command inspect unmodified files as candidates
1992 for the source of copy. This is a very expensive operation for
1993 large projects, so use it with caution. Giving more than one -C
1994 option has the same effect.
1995
1996 -D, --irreversible-delete
1997 Omit the preimage for deletes, i.e. print only the header but not
1998 the diff between the preimage and /dev/null. The resulting patch is
1999 not meant to be applied with patch or git apply; this is solely for
2000 people who want to just concentrate on reviewing the text after the
2001 change. In addition, the output obviously lacks enough information
2002 to apply such a patch in reverse, even manually, hence the name of
2003 the option.
2004
2005 When used together with -B, omit also the preimage in the deletion
2006 part of a delete/create pair.
2007
2008 -l<num>
2009 The -M and -C options require O(n^2) processing time where n is the
2010 number of potential rename/copy targets. This option prevents
2011 rename/copy detection from running if the number of rename/copy
2012 targets exceeds the specified number.
2013
2014 --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
2015 Select only files that are Added (A), Copied (C), Deleted (D),
2016 Modified (M), Renamed (R), have their type (i.e. regular file,
2017 symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown
2018 (X), or have had their pairing Broken (B). Any combination of the
2019 filter characters (including none) can be used. When *
2020 (All-or-none) is added to the combination, all paths are selected
2021 if there is any file that matches other criteria in the comparison;
2022 if there is no file that matches other criteria, nothing is
2023 selected.
2024
2025 Also, these upper-case letters can be downcased to exclude. E.g.
2026 --diff-filter=ad excludes added and deleted paths.
2027
2028 Note that not all diffs can feature all types. For instance, diffs
2029 from the index to the working tree can never have Added entries
2030 (because the set of paths included in the diff is limited by what
2031 is in the index). Similarly, copied and renamed entries cannot
2032 appear if detection for those types is disabled.
2033
2034 -S<string>
2035 Look for differences that change the number of occurrences of the
2036 specified string (i.e. addition/deletion) in a file. Intended for
2037 the scripter’s use.
2038
2039 It is useful when you’re looking for an exact block of code (like a
2040 struct), and want to know the history of that block since it first
2041 came into being: use the feature iteratively to feed the
2042 interesting block in the preimage back into -S, and keep going
2043 until you get the very first version of the block.
2044
2045 Binary files are searched as well.
2046
2047 -G<regex>
2048 Look for differences whose patch text contains added/removed lines
2049 that match <regex>.
2050
2051 To illustrate the difference between -S<regex> --pickaxe-regex and
2052 -G<regex>, consider a commit with the following diff in the same
2053 file:
2054
2055 + return frotz(nitfol, two->ptr, 1, 0);
2056 ...
2057 - hit = frotz(nitfol, mf2.ptr, 1, 0);
2058
2059 While git log -G"frotz\(nitfol" will show this commit, git log
2060 -S"frotz\(nitfol" --pickaxe-regex will not (because the number of
2061 occurrences of that string did not change).
2062
2063 Unless --text is supplied patches of binary files without a
2064 textconv filter will be ignored.
2065
2066 See the pickaxe entry in gitdiffcore(7) for more information.
2067
2068 --find-object=<object-id>
2069 Look for differences that change the number of occurrences of the
2070 specified object. Similar to -S, just the argument is different in
2071 that it doesn’t search for a specific string but for a specific
2072 object id.
2073
2074 The object can be a blob or a submodule commit. It implies the -t
2075 option in git-log to also find trees.
2076
2077 --pickaxe-all
2078 When -S or -G finds a change, show all the changes in that
2079 changeset, not just the files that contain the change in <string>.
2080
2081 --pickaxe-regex
2082 Treat the <string> given to -S as an extended POSIX regular
2083 expression to match.
2084
2085 -O<orderfile>
2086 Control the order in which files appear in the output. This
2087 overrides the diff.orderFile configuration variable (see git-
2088 config(1)). To cancel diff.orderFile, use -O/dev/null.
2089
2090 The output order is determined by the order of glob patterns in
2091 <orderfile>. All files with pathnames that match the first pattern
2092 are output first, all files with pathnames that match the second
2093 pattern (but not the first) are output next, and so on. All files
2094 with pathnames that do not match any pattern are output last, as if
2095 there was an implicit match-all pattern at the end of the file. If
2096 multiple pathnames have the same rank (they match the same pattern
2097 but no earlier patterns), their output order relative to each other
2098 is the normal order.
2099
2100 <orderfile> is parsed as follows:
2101
2102 • Blank lines are ignored, so they can be used as separators for
2103 readability.
2104
2105 • Lines starting with a hash ("#") are ignored, so they can be
2106 used for comments. Add a backslash ("\") to the beginning of
2107 the pattern if it starts with a hash.
2108
2109 • Each other line contains a single pattern.
2110
2111 Patterns have the same syntax and semantics as patterns used for
2112 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
2113 matches a pattern if removing any number of the final pathname
2114 components matches the pattern. For example, the pattern "foo*bar"
2115 matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".
2116
2117 --skip-to=<file>, --rotate-to=<file>
2118 Discard the files before the named <file> from the output (i.e.
2119 skip to), or move them to the end of the output (i.e. rotate to).
2120 These were invented primarily for use of the git difftool command,
2121 and may not be very useful otherwise.
2122
2123 -R
2124 Swap two inputs; that is, show differences from index or on-disk
2125 file to tree contents.
2126
2127 --relative[=<path>], --no-relative
2128 When run from a subdirectory of the project, it can be told to
2129 exclude changes outside the directory and show pathnames relative
2130 to it with this option. When you are not in a subdirectory (e.g. in
2131 a bare repository), you can name which subdirectory to make the
2132 output relative to by giving a <path> as an argument.
2133 --no-relative can be used to countermand both diff.relative config
2134 option and previous --relative.
2135
2136 -a, --text
2137 Treat all files as text.
2138
2139 --ignore-cr-at-eol
2140 Ignore carriage-return at the end of line when doing a comparison.
2141
2142 --ignore-space-at-eol
2143 Ignore changes in whitespace at EOL.
2144
2145 -b, --ignore-space-change
2146 Ignore changes in amount of whitespace. This ignores whitespace at
2147 line end, and considers all other sequences of one or more
2148 whitespace characters to be equivalent.
2149
2150 -w, --ignore-all-space
2151 Ignore whitespace when comparing lines. This ignores differences
2152 even if one line has whitespace where the other line has none.
2153
2154 --ignore-blank-lines
2155 Ignore changes whose lines are all blank.
2156
2157 -I<regex>, --ignore-matching-lines=<regex>
2158 Ignore changes whose all lines match <regex>. This option may be
2159 specified more than once.
2160
2161 --inter-hunk-context=<lines>
2162 Show the context between diff hunks, up to the specified number of
2163 lines, thereby fusing hunks that are close to each other. Defaults
2164 to diff.interHunkContext or 0 if the config option is unset.
2165
2166 -W, --function-context
2167 Show whole function as context lines for each change. The function
2168 names are determined in the same way as git diff works out patch
2169 hunk headers (see Defining a custom hunk-header in
2170 gitattributes(5)).
2171
2172 --ext-diff
2173 Allow an external diff helper to be executed. If you set an
2174 external diff driver with gitattributes(5), you need to use this
2175 option with git-log(1) and friends.
2176
2177 --no-ext-diff
2178 Disallow external diff drivers.
2179
2180 --textconv, --no-textconv
2181 Allow (or disallow) external text conversion filters to be run when
2182 comparing binary files. See gitattributes(5) for details. Because
2183 textconv filters are typically a one-way conversion, the resulting
2184 diff is suitable for human consumption, but cannot be applied. For
2185 this reason, textconv filters are enabled by default only for git-
2186 diff(1) and git-log(1), but not for git-format-patch(1) or diff
2187 plumbing commands.
2188
2189 --ignore-submodules[=<when>]
2190 Ignore changes to submodules in the diff generation. <when> can be
2191 either "none", "untracked", "dirty" or "all", which is the default.
2192 Using "none" will consider the submodule modified when it either
2193 contains untracked or modified files or its HEAD differs from the
2194 commit recorded in the superproject and can be used to override any
2195 settings of the ignore option in git-config(1) or gitmodules(5).
2196 When "untracked" is used submodules are not considered dirty when
2197 they only contain untracked content (but they are still scanned for
2198 modified content). Using "dirty" ignores all changes to the work
2199 tree of submodules, only changes to the commits stored in the
2200 superproject are shown (this was the behavior until 1.7.0). Using
2201 "all" hides all changes to submodules.
2202
2203 --src-prefix=<prefix>
2204 Show the given source prefix instead of "a/".
2205
2206 --dst-prefix=<prefix>
2207 Show the given destination prefix instead of "b/".
2208
2209 --no-prefix
2210 Do not show any source or destination prefix.
2211
2212 --line-prefix=<prefix>
2213 Prepend an additional prefix to every line of output.
2214
2215 --ita-invisible-in-index
2216 By default entries added by "git add -N" appear as an existing
2217 empty file in "git diff" and a new file in "git diff --cached".
2218 This option makes the entry appear as a new file in "git diff" and
2219 non-existent in "git diff --cached". This option could be reverted
2220 with --ita-visible-in-index. Both options are experimental and
2221 could be removed in future.
2222
2223 For more detailed explanation on these common options, see also
2224 gitdiffcore(7).
2225
2227 Running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-
2228 diff-tree(1), or git-diff-files(1) with the -p option produces patch
2229 text. You can customize the creation of patch text via the
2230 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables (see
2231 git(1)).
2232
2233 What the -p option produces is slightly different from the traditional
2234 diff format:
2235
2236 1. It is preceded with a "git diff" header that looks like this:
2237
2238 diff --git a/file1 b/file2
2239
2240 The a/ and b/ filenames are the same unless rename/copy is
2241 involved. Especially, even for a creation or a deletion, /dev/null
2242 is not used in place of the a/ or b/ filenames.
2243
2244 When rename/copy is involved, file1 and file2 show the name of the
2245 source file of the rename/copy and the name of the file that
2246 rename/copy produces, respectively.
2247
2248 2. It is followed by one or more extended header lines:
2249
2250 old mode <mode>
2251 new mode <mode>
2252 deleted file mode <mode>
2253 new file mode <mode>
2254 copy from <path>
2255 copy to <path>
2256 rename from <path>
2257 rename to <path>
2258 similarity index <number>
2259 dissimilarity index <number>
2260 index <hash>..<hash> <mode>
2261
2262 File modes are printed as 6-digit octal numbers including the file
2263 type and file permission bits.
2264
2265 Path names in extended headers do not include the a/ and b/
2266 prefixes.
2267
2268 The similarity index is the percentage of unchanged lines, and the
2269 dissimilarity index is the percentage of changed lines. It is a
2270 rounded down integer, followed by a percent sign. The similarity
2271 index value of 100% is thus reserved for two equal files, while
2272 100% dissimilarity means that no line from the old file made it
2273 into the new one.
2274
2275 The index line includes the blob object names before and after the
2276 change. The <mode> is included if the file mode does not change;
2277 otherwise, separate lines indicate the old and the new mode.
2278
2279 3. Pathnames with "unusual" characters are quoted as explained for the
2280 configuration variable core.quotePath (see git-config(1)).
2281
2282 4. All the file1 files in the output refer to files before the commit,
2283 and all the file2 files refer to files after the commit. It is
2284 incorrect to apply each change to each file sequentially. For
2285 example, this patch will swap a and b:
2286
2287 diff --git a/a b/b
2288 rename from a
2289 rename to b
2290 diff --git a/b b/a
2291 rename from b
2292 rename to a
2293
2295 Any diff-generating command can take the -c or --cc option to produce a
2296 combined diff when showing a merge. This is the default format when
2297 showing merges with git-diff(1) or git-show(1). Note also that you can
2298 give suitable --diff-merges option to any of these commands to force
2299 generation of diffs in specific format.
2300
2301 A "combined diff" format looks like this:
2302
2303 diff --combined describe.c
2304 index fabadb8,cc95eb0..4866510
2305 --- a/describe.c
2306 +++ b/describe.c
2307 @@@ -98,20 -98,12 +98,20 @@@
2308 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
2309 }
2310
2311 - static void describe(char *arg)
2312 -static void describe(struct commit *cmit, int last_one)
2313 ++static void describe(char *arg, int last_one)
2314 {
2315 + unsigned char sha1[20];
2316 + struct commit *cmit;
2317 struct commit_list *list;
2318 static int initialized = 0;
2319 struct commit_name *n;
2320
2321 + if (get_sha1(arg, sha1) < 0)
2322 + usage(describe_usage);
2323 + cmit = lookup_commit_reference(sha1);
2324 + if (!cmit)
2325 + usage(describe_usage);
2326 +
2327 if (!initialized) {
2328 initialized = 1;
2329 for_each_ref(get_name);
2330
2331 1. It is preceded with a "git diff" header, that looks like this (when
2332 the -c option is used):
2333
2334 diff --combined file
2335
2336 or like this (when the --cc option is used):
2337
2338 diff --cc file
2339
2340 2. It is followed by one or more extended header lines (this example
2341 shows a merge with two parents):
2342
2343 index <hash>,<hash>..<hash>
2344 mode <mode>,<mode>..<mode>
2345 new file mode <mode>
2346 deleted file mode <mode>,<mode>
2347
2348 The mode <mode>,<mode>..<mode> line appears only if at least one of
2349 the <mode> is different from the rest. Extended headers with
2350 information about detected contents movement (renames and copying
2351 detection) are designed to work with diff of two <tree-ish> and are
2352 not used by combined diff format.
2353
2354 3. It is followed by two-line from-file/to-file header
2355
2356 --- a/file
2357 +++ b/file
2358
2359 Similar to two-line header for traditional unified diff format,
2360 /dev/null is used to signal created or deleted files.
2361
2362 However, if the --combined-all-paths option is provided, instead of
2363 a two-line from-file/to-file you get a N+1 line from-file/to-file
2364 header, where N is the number of parents in the merge commit
2365
2366 --- a/file
2367 --- a/file
2368 --- a/file
2369 +++ b/file
2370
2371 This extended format can be useful if rename or copy detection is
2372 active, to allow you to see the original name of the file in
2373 different parents.
2374
2375 4. Chunk header format is modified to prevent people from accidentally
2376 feeding it to patch -p1. Combined diff format was created for
2377 review of merge commit changes, and was not meant to be applied.
2378 The change is similar to the change in the extended index header:
2379
2380 @@@ <from-file-range> <from-file-range> <to-file-range> @@@
2381
2382 There are (number of parents + 1) @ characters in the chunk header
2383 for combined diff format.
2384
2385 Unlike the traditional unified diff format, which shows two files A and
2386 B with a single column that has - (minus — appears in A but removed in
2387 B), + (plus — missing in A but added to B), or " " (space — unchanged)
2388 prefix, this format compares two or more files file1, file2,... with
2389 one file X, and shows how X differs from each of fileN. One column for
2390 each of fileN is prepended to the output line to note how X’s line is
2391 different from it.
2392
2393 A - character in the column N means that the line appears in fileN but
2394 it does not appear in the result. A + character in the column N means
2395 that the line appears in the result, and fileN does not have that line
2396 (in other words, the line was added, from the point of view of that
2397 parent).
2398
2399 In the above example output, the function signature was changed from
2400 both files (hence two - removals from both file1 and file2, plus ++ to
2401 mean one line that was added does not appear in either file1 or file2).
2402 Also eight other lines are the same from file1 but do not appear in
2403 file2 (hence prefixed with +).
2404
2405 When shown by git diff-tree -c, it compares the parents of a merge
2406 commit with the merge result (i.e. file1..fileN are the parents). When
2407 shown by git diff-files -c, it compares the two unresolved merge
2408 parents with the working tree file (i.e. file1 is stage 2 aka "our
2409 version", file2 is stage 3 aka "their version").
2410
2412 git log --no-merges
2413 Show the whole commit history, but skip any merges
2414
2415 git log v2.6.12.. include/scsi drivers/scsi
2416 Show all commits since version v2.6.12 that changed any file in the
2417 include/scsi or drivers/scsi subdirectories
2418
2419 git log --since="2 weeks ago" -- gitk
2420 Show the changes during the last two weeks to the file gitk. The --
2421 is necessary to avoid confusion with the branch named gitk
2422
2423 git log --name-status release..test
2424 Show the commits that are in the "test" branch but not yet in the
2425 "release" branch, along with the list of paths each commit
2426 modifies.
2427
2428 git log --follow builtin/rev-list.c
2429 Shows the commits that changed builtin/rev-list.c, including those
2430 commits that occurred before the file was given its present name.
2431
2432 git log --branches --not --remotes=origin
2433 Shows all commits that are in any of local branches but not in any
2434 of remote-tracking branches for origin (what you have that origin
2435 doesn’t).
2436
2437 git log master --not --remotes=*/master
2438 Shows all commits that are in local master but not in any remote
2439 repository master branches.
2440
2441 git log -p -m --first-parent
2442 Shows the history including change diffs, but only from the “main
2443 branch” perspective, skipping commits that come from merged
2444 branches, and showing full diffs of changes introduced by the
2445 merges. This makes sense only when following a strict policy of
2446 merging all topic branches when staying on a single integration
2447 branch.
2448
2449 git log -L '/int main/',/^}/:main.c
2450 Shows how the function main() in the file main.c evolved over time.
2451
2452 git log -3
2453 Limits the number of commits to show to 3.
2454
2456 Git is to some extent character encoding agnostic.
2457
2458 • The contents of the blob objects are uninterpreted sequences of
2459 bytes. There is no encoding translation at the core level.
2460
2461 • Path names are encoded in UTF-8 normalization form C. This applies
2462 to tree objects, the index file, ref names, as well as path names
2463 in command line arguments, environment variables and config files
2464 (.git/config (see git-config(1)), gitignore(5), gitattributes(5)
2465 and gitmodules(5)).
2466
2467 Note that Git at the core level treats path names simply as
2468 sequences of non-NUL bytes, there are no path name encoding
2469 conversions (except on Mac and Windows). Therefore, using non-ASCII
2470 path names will mostly work even on platforms and file systems that
2471 use legacy extended ASCII encodings. However, repositories created
2472 on such systems will not work properly on UTF-8-based systems (e.g.
2473 Linux, Mac, Windows) and vice versa. Additionally, many Git-based
2474 tools simply assume path names to be UTF-8 and will fail to display
2475 other encodings correctly.
2476
2477 • Commit log messages are typically encoded in UTF-8, but other
2478 extended ASCII encodings are also supported. This includes
2479 ISO-8859-x, CP125x and many others, but not UTF-16/32, EBCDIC and
2480 CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x, CP9xx etc.).
2481
2482 Although we encourage that the commit log messages are encoded in
2483 UTF-8, both the core and Git Porcelain are designed not to force UTF-8
2484 on projects. If all participants of a particular project find it more
2485 convenient to use legacy encodings, Git does not forbid it. However,
2486 there are a few things to keep in mind.
2487
2488 1. git commit and git commit-tree issues a warning if the commit log
2489 message given to it does not look like a valid UTF-8 string, unless
2490 you explicitly say your project uses a legacy encoding. The way to
2491 say this is to have i18n.commitEncoding in .git/config file, like
2492 this:
2493
2494 [i18n]
2495 commitEncoding = ISO-8859-1
2496
2497 Commit objects created with the above setting record the value of
2498 i18n.commitEncoding in its encoding header. This is to help other
2499 people who look at them later. Lack of this header implies that the
2500 commit log message is encoded in UTF-8.
2501
2502 2. git log, git show, git blame and friends look at the encoding
2503 header of a commit object, and try to re-code the log message into
2504 UTF-8 unless otherwise specified. You can specify the desired
2505 output encoding with i18n.logOutputEncoding in .git/config file,
2506 like this:
2507
2508 [i18n]
2509 logOutputEncoding = ISO-8859-1
2510
2511 If you do not have this configuration variable, the value of
2512 i18n.commitEncoding is used instead.
2513
2514 Note that we deliberately chose not to re-code the commit log message
2515 when a commit is made to force UTF-8 at the commit object level,
2516 because re-coding to UTF-8 is not necessarily a reversible operation.
2517
2519 See git-config(1) for core variables and git-diff(1) for settings
2520 related to diff generation.
2521
2522 format.pretty
2523 Default for the --format option. (See Pretty Formats above.)
2524 Defaults to medium.
2525
2526 i18n.logOutputEncoding
2527 Encoding to use when displaying logs. (See Discussion above.)
2528 Defaults to the value of i18n.commitEncoding if set, and UTF-8
2529 otherwise.
2530
2531 log.date
2532 Default format for human-readable dates. (Compare the --date
2533 option.) Defaults to "default", which means to write dates like Sat
2534 May 8 19:35:34 2010 -0500.
2535
2536 If the format is set to "auto:foo" and the pager is in use, format
2537 "foo" will be the used for the date format. Otherwise "default"
2538 will be used.
2539
2540 log.follow
2541 If true, git log will act as if the --follow option was used when a
2542 single <path> is given. This has the same limitations as --follow,
2543 i.e. it cannot be used to follow multiple files and does not work
2544 well on non-linear history.
2545
2546 log.showRoot
2547 If false, git log and related commands will not treat the initial
2548 commit as a big creation event. Any root commits in git log -p
2549 output would be shown without a diff attached. The default is true.
2550
2551 log.showSignature
2552 If true, git log and related commands will act as if the
2553 --show-signature option was passed to them.
2554
2555 mailmap.*
2556 See git-shortlog(1).
2557
2558 notes.displayRef
2559 Which refs, in addition to the default set by core.notesRef or
2560 GIT_NOTES_REF, to read notes from when showing commit messages with
2561 the log family of commands. See git-notes(1).
2562
2563 May be an unabbreviated ref name or a glob and may be specified
2564 multiple times. A warning will be issued for refs that do not
2565 exist, but a glob that does not match any refs is silently ignored.
2566
2567 This setting can be disabled by the --no-notes option, overridden
2568 by the GIT_NOTES_DISPLAY_REF environment variable, and overridden
2569 by the --notes=<ref> option.
2570
2572 Part of the git(1) suite
2573
2574
2575
2576Git 2.31.1 2021-03-26 GIT-LOG(1)