1Commit Limiting 2~~~~~~~~~~~~~~~ 3 4Besides specifying a range of commits that should be listed using the 5special notations explained in the description, additional commit 6limiting may be applied. Note that they are applied before commit 7ordering and formatting options, such as '--reverse'. 8 9-- 10 11-n 'number':: 12--max-count=<number>:: 13 14 Limit the number of commits to output. 15 16--skip=<number>:: 17 18 Skip 'number' commits before starting to show the commit output. 19 20--since=<date>:: 21--after=<date>:: 22 23 Show commits more recent than a specific date. 24 25--until=<date>:: 26--before=<date>:: 27 28 Show commits older than a specific date. 29 30ifdef::git-rev-list[] 31--max-age=<timestamp>:: 32--min-age=<timestamp>:: 33 34 Limit the commits output to specified time range. 35endif::git-rev-list[] 36 37--author=<pattern>:: 38--committer=<pattern>:: 39 40 Limit the commits output to ones with author/committer 41 header lines that match the specified pattern (regular expression). 42 43--grep=<pattern>:: 44 45 Limit the commits output to ones with log message that 46 matches the specified pattern (regular expression). 47 48--all-match:: 49 Limit the commits output to ones that match all given --grep, 50 --author and --committer instead of ones that match at least one. 51 52-i:: 53--regexp-ignore-case:: 54 55 Match the regexp limiting patterns without regard to letters case. 56 57-E:: 58--extended-regexp:: 59 60 Consider the limiting patterns to be extended regular expressions 61 instead of the default basic regular expressions. 62 63-F:: 64--fixed-strings:: 65 66 Consider the limiting patterns to be fixed strings (don't interpret 67 pattern as a regular expression). 68 69--remove-empty:: 70 71 Stop when a given path disappears from the tree. 72 73--merges:: 74 75 Print only merge commits. This is exactly the same as `--min-parents=2`. 76 77--no-merges:: 78 79 Do not print commits with more than one parent. This is 80 exactly the same as `--max-parents=1`. 81 82--min-parents=<number>:: 83--max-parents=<number>:: 84--no-min-parents:: 85--no-max-parents:: 86 87 Show only commits which have at least (or at most) that many 88 commits. In particular, `--max-parents=1` is the same as `--no-merges`, 89 `--min-parents=2` is the same as `--merges`. `--max-parents=0` 90 gives all root commits and `--min-parents=3` all octopus merges. 91+ 92`--no-min-parents` and `--no-max-parents` reset these limits (to no limit) 93again. Equivalent forms are `--min-parents=0` (any commit has 0 or more 94parents) and `--max-parents=-1` (negative numbers denote no upper limit). 95 96--first-parent:: 97 Follow only the first parent commit upon seeing a merge 98 commit. This option can give a better overview when 99 viewing the evolution of a particular topic branch, 100 because merges into a topic branch tend to be only about 101 adjusting to updated upstream from time to time, and 102 this option allows you to ignore the individual commits 103 brought in to your history by such a merge. 104 105--not:: 106 107 Reverses the meaning of the '{caret}' prefix (or lack thereof) 108 for all following revision specifiers, up to the next '--not'. 109 110--all:: 111 112 Pretend as if all the refs in `refs/` are listed on the 113 command line as '<commit>'. 114 115--branches[=<pattern>]:: 116 117 Pretend as if all the refs in `refs/heads` are listed 118 on the command line as '<commit>'. If '<pattern>' is given, limit 119 branches to ones matching given shell glob. If pattern lacks '?', 120 '*', or '[', '/*' at the end is implied. 121 122--tags[=<pattern>]:: 123 124 Pretend as if all the refs in `refs/tags` are listed 125 on the command line as '<commit>'. If '<pattern>' is given, limit 126 tags to ones matching given shell glob. If pattern lacks '?', '*', 127 or '[', '/*' at the end is implied. 128 129--remotes[=<pattern>]:: 130 131 Pretend as if all the refs in `refs/remotes` are listed 132 on the command line as '<commit>'. If '<pattern>' is given, limit 133 remote-tracking branches to ones matching given shell glob. 134 If pattern lacks '?', '*', or '[', '/*' at the end is implied. 135 136--glob=<glob-pattern>:: 137 Pretend as if all the refs matching shell glob '<glob-pattern>' 138 are listed on the command line as '<commit>'. Leading 'refs/', 139 is automatically prepended if missing. If pattern lacks '?', '*', 140 or '[', '/*' at the end is implied. 141 142 143ifndef::git-rev-list[] 144--bisect:: 145 146 Pretend as if the bad bisection ref `refs/bisect/bad` 147 was listed and as if it was followed by `--not` and the good 148 bisection refs `refs/bisect/good-*` on the command 149 line. 150endif::git-rev-list[] 151 152--stdin:: 153 154 In addition to the '<commit>' listed on the command 155 line, read them from the standard input. If a '--' separator is 156 seen, stop reading commits and start reading paths to limit the 157 result. 158 159ifdef::git-rev-list[] 160--quiet:: 161 162 Don't print anything to standard output. This form 163 is primarily meant to allow the caller to 164 test the exit status to see if a range of objects is fully 165 connected (or not). It is faster than redirecting stdout 166 to /dev/null as the output does not have to be formatted. 167endif::git-rev-list[] 168 169--cherry-mark:: 170 171 Like `--cherry-pick` (see below) but mark equivalent commits 172 with `=` rather than omitting them, and inequivalent ones with `+`. 173 174--cherry-pick:: 175 176 Omit any commit that introduces the same change as 177 another commit on the "other side" when the set of 178 commits are limited with symmetric difference. 179+ 180For example, if you have two branches, `A` and `B`, a usual way 181to list all commits on only one side of them is with 182`--left-right` (see the example below in the description of 183the `--left-right` option). It however shows the commits that were cherry-picked 184from the other branch (for example, "3rd on b" may be cherry-picked 185from branch A). With this option, such pairs of commits are 186excluded from the output. 187 188--left-only:: 189--right-only:: 190 191 List only commits on the respective side of a symmetric range, 192 i.e. only those which would be marked `<` resp. `>` by 193 `--left-right`. 194+ 195For example, `--cherry-pick --right-only A...B` omits those 196commits from `B` which are in `A` or are patch-equivalent to a commit in 197`A`. In other words, this lists the `{plus}` commits from `git cherry A B`. 198More precisely, `--cherry-pick --right-only --no-merges` gives the exact 199list. 200 201--cherry:: 202 203 A synonym for `--right-only --cherry-mark --no-merges`; useful to 204 limit the output to the commits on our side and mark those that 205 have been applied to the other side of a forked history with 206 `git log --cherry upstream...mybranch`, similar to 207 `git cherry upstream mybranch`. 208 209-g:: 210--walk-reflogs:: 211 212 Instead of walking the commit ancestry chain, walk 213 reflog entries from the most recent one to older ones. 214 When this option is used you cannot specify commits to 215 exclude (that is, '{caret}commit', 'commit1..commit2', 216 nor 'commit1\...commit2' notations cannot be used). 217+ 218With '\--pretty' format other than oneline (for obvious reasons), 219this causes the output to have two extra lines of information 220taken from the reflog. By default, 'commit@\{Nth}' notation is 221used in the output. When the starting commit is specified as 222'commit@\{now}', output also uses 'commit@\{timestamp}' notation 223instead. Under '\--pretty=oneline', the commit message is 224prefixed with this information on the same line. 225This option cannot be combined with '\--reverse'. 226See also linkgit:git-reflog[1]. 227 228--merge:: 229 230 After a failed merge, show refs that touch files having a 231 conflict and don't exist on all heads to merge. 232 233--boundary:: 234 235 Output uninteresting commits at the boundary, which are usually 236 not shown. 237 238-- 239 240History Simplification 241~~~~~~~~~~~~~~~~~~~~~~ 242 243Sometimes you are only interested in parts of the history, for example the 244commits modifying a particular <path>. But there are two parts of 245'History Simplification', one part is selecting the commits and the other 246is how to do it, as there are various strategies to simplify the history. 247 248The following options select the commits to be shown: 249 250<paths>:: 251 252 Commits modifying the given <paths> are selected. 253 254--simplify-by-decoration:: 255 256 Commits that are referred by some branch or tag are selected. 257 258Note that extra commits can be shown to give a meaningful history. 259 260The following options affect the way the simplification is performed: 261 262Default mode:: 263 264 Simplifies the history to the simplest history explaining the 265 final state of the tree. Simplest because it prunes some side 266 branches if the end result is the same (i.e. merging branches 267 with the same content) 268 269--full-history:: 270 271 As the default mode but does not prune some history. 272 273--dense:: 274 275 Only the selected commits are shown, plus some to have a 276 meaningful history. 277 278--sparse:: 279 280 All commits in the simplified history are shown. 281 282--simplify-merges:: 283 284 Additional option to '--full-history' to remove some needless 285 merges from the resulting history, as there are no selected 286 commits contributing to this merge. 287 288--ancestry-path:: 289 290 When given a range of commits to display (e.g. 'commit1..commit2' 291 or 'commit2 {caret}commit1'), only display commits that exist 292 directly on the ancestry chain between the 'commit1' and 293 'commit2', i.e. commits that are both descendants of 'commit1', 294 and ancestors of 'commit2'. 295 296A more detailed explanation follows. 297 298Suppose you specified `foo` as the <paths>. We shall call commits 299that modify `foo` !TREESAME, and the rest TREESAME. (In a diff 300filtered for `foo`, they look different and equal, respectively.) 301 302In the following, we will always refer to the same example history to 303illustrate the differences between simplification settings. We assume 304that you are filtering for a file `foo` in this commit graph: 305----------------------------------------------------------------------- 306 .-A---M---N---O---P 307 / / / / / 308 I B C D E 309 \ / / / / 310 `-------------' 311----------------------------------------------------------------------- 312The horizontal line of history A--P is taken to be the first parent of 313each merge. The commits are: 314 315* `I` is the initial commit, in which `foo` exists with contents 316 "asdf", and a file `quux` exists with contents "quux". Initial 317 commits are compared to an empty tree, so `I` is !TREESAME. 318 319* In `A`, `foo` contains just "foo". 320 321* `B` contains the same change as `A`. Its merge `M` is trivial and 322 hence TREESAME to all parents. 323 324* `C` does not change `foo`, but its merge `N` changes it to "foobar", 325 so it is not TREESAME to any parent. 326 327* `D` sets `foo` to "baz". Its merge `O` combines the strings from 328 `N` and `D` to "foobarbaz"; i.e., it is not TREESAME to any parent. 329 330* `E` changes `quux` to "xyzzy", and its merge `P` combines the 331 strings to "quux xyzzy". Despite appearing interesting, `P` is 332 TREESAME to all parents. 333 334'rev-list' walks backwards through history, including or excluding 335commits based on whether '\--full-history' and/or parent rewriting 336(via '\--parents' or '\--children') are used. The following settings 337are available. 338 339Default mode:: 340 341 Commits are included if they are not TREESAME to any parent 342 (though this can be changed, see '\--sparse' below). If the 343 commit was a merge, and it was TREESAME to one parent, follow 344 only that parent. (Even if there are several TREESAME 345 parents, follow only one of them.) Otherwise, follow all 346 parents. 347+ 348This results in: 349+ 350----------------------------------------------------------------------- 351 .-A---N---O 352 / / / 353 I---------D 354----------------------------------------------------------------------- 355+ 356Note how the rule to only follow the TREESAME parent, if one is 357available, removed `B` from consideration entirely. `C` was 358considered via `N`, but is TREESAME. Root commits are compared to an 359empty tree, so `I` is !TREESAME. 360+ 361Parent/child relations are only visible with --parents, but that does 362not affect the commits selected in default mode, so we have shown the 363parent lines. 364 365--full-history without parent rewriting:: 366 367 This mode differs from the default in one point: always follow 368 all parents of a merge, even if it is TREESAME to one of them. 369 Even if more than one side of the merge has commits that are 370 included, this does not imply that the merge itself is! In 371 the example, we get 372+ 373----------------------------------------------------------------------- 374 I A B N D O 375----------------------------------------------------------------------- 376+ 377`P` and `M` were excluded because they are TREESAME to a parent. `E`, 378`C` and `B` were all walked, but only `B` was !TREESAME, so the others 379do not appear. 380+ 381Note that without parent rewriting, it is not really possible to talk 382about the parent/child relationships between the commits, so we show 383them disconnected. 384 385--full-history with parent rewriting:: 386 387 Ordinary commits are only included if they are !TREESAME 388 (though this can be changed, see '\--sparse' below). 389+ 390Merges are always included. However, their parent list is rewritten: 391Along each parent, prune away commits that are not included 392themselves. This results in 393+ 394----------------------------------------------------------------------- 395 .-A---M---N---O---P 396 / / / / / 397 I B / D / 398 \ / / / / 399 `-------------' 400----------------------------------------------------------------------- 401+ 402Compare to '\--full-history' without rewriting above. Note that `E` 403was pruned away because it is TREESAME, but the parent list of P was 404rewritten to contain `E`'s parent `I`. The same happened for `C` and 405`N`. Note also that `P` was included despite being TREESAME. 406 407In addition to the above settings, you can change whether TREESAME 408affects inclusion: 409 410--dense:: 411 412 Commits that are walked are included if they are not TREESAME 413 to any parent. 414 415--sparse:: 416 417 All commits that are walked are included. 418+ 419Note that without '\--full-history', this still simplifies merges: if 420one of the parents is TREESAME, we follow only that one, so the other 421sides of the merge are never walked. 422 423--simplify-merges:: 424 425 First, build a history graph in the same way that 426 '\--full-history' with parent rewriting does (see above). 427+ 428Then simplify each commit `C` to its replacement `C'` in the final 429history according to the following rules: 430+ 431-- 432* Set `C'` to `C`. 433+ 434* Replace each parent `P` of `C'` with its simplification `P'`. In 435 the process, drop parents that are ancestors of other parents, and 436 remove duplicates. 437+ 438* If after this parent rewriting, `C'` is a root or merge commit (has 439 zero or >1 parents), a boundary commit, or !TREESAME, it remains. 440 Otherwise, it is replaced with its only parent. 441-- 442+ 443The effect of this is best shown by way of comparing to 444'\--full-history' with parent rewriting. The example turns into: 445+ 446----------------------------------------------------------------------- 447 .-A---M---N---O 448 / / / 449 I B D 450 \ / / 451 `---------' 452----------------------------------------------------------------------- 453+ 454Note the major differences in `N` and `P` over '\--full-history': 455+ 456-- 457* `N`'s parent list had `I` removed, because it is an ancestor of the 458 other parent `M`. Still, `N` remained because it is !TREESAME. 459+ 460* `P`'s parent list similarly had `I` removed. `P` was then 461 removed completely, because it had one parent and is TREESAME. 462-- 463 464Finally, there is a fifth simplification mode available: 465 466--ancestry-path:: 467 468 Limit the displayed commits to those directly on the ancestry 469 chain between the "from" and "to" commits in the given commit 470 range. I.e. only display commits that are ancestor of the "to" 471 commit, and descendants of the "from" commit. 472+ 473As an example use case, consider the following commit history: 474+ 475----------------------------------------------------------------------- 476 D---E-------F 477 / \ \ 478 B---C---G---H---I---J 479 / \ 480 A-------K---------------L--M 481----------------------------------------------------------------------- 482+ 483A regular 'D..M' computes the set of commits that are ancestors of `M`, 484but excludes the ones that are ancestors of `D`. This is useful to see 485what happened to the history leading to `M` since `D`, in the sense 486that "what does `M` have that did not exist in `D`". The result in this 487example would be all the commits, except `A` and `B` (and `D` itself, 488of course). 489+ 490When we want to find out what commits in `M` are contaminated with the 491bug introduced by `D` and need fixing, however, we might want to view 492only the subset of 'D..M' that are actually descendants of `D`, i.e. 493excluding `C` and `K`. This is exactly what the '\--ancestry-path' 494option does. Applied to the 'D..M' range, it results in: 495+ 496----------------------------------------------------------------------- 497 E-------F 498 \ \ 499 G---H---I---J 500 \ 501 L--M 502----------------------------------------------------------------------- 503 504The '\--simplify-by-decoration' option allows you to view only the 505big picture of the topology of the history, by omitting commits 506that are not referenced by tags. Commits are marked as !TREESAME 507(in other words, kept after history simplification rules described 508above) if (1) they are referenced by tags, or (2) they change the 509contents of the paths given on the command line. All other 510commits are marked as TREESAME (subject to be simplified away). 511 512ifdef::git-rev-list[] 513Bisection Helpers 514~~~~~~~~~~~~~~~~~ 515 516--bisect:: 517 518Limit output to the one commit object which is roughly halfway between 519included and excluded commits. Note that the bad bisection ref 520`refs/bisect/bad` is added to the included commits (if it 521exists) and the good bisection refs `refs/bisect/good-*` are 522added to the excluded commits (if they exist). Thus, supposing there 523are no refs in `refs/bisect/`, if 524 525----------------------------------------------------------------------- 526 $ git rev-list --bisect foo ^bar ^baz 527----------------------------------------------------------------------- 528 529outputs 'midpoint', the output of the two commands 530 531----------------------------------------------------------------------- 532 $ git rev-list foo ^midpoint 533 $ git rev-list midpoint ^bar ^baz 534----------------------------------------------------------------------- 535 536would be of roughly the same length. Finding the change which 537introduces a regression is thus reduced to a binary search: repeatedly 538generate and test new 'midpoint's until the commit chain is of length 539one. 540 541--bisect-vars:: 542 543This calculates the same as `--bisect`, except that refs in 544`refs/bisect/` are not used, and except that this outputs 545text ready to be eval'ed by the shell. These lines will assign the 546name of the midpoint revision to the variable `bisect_rev`, and the 547expected number of commits to be tested after `bisect_rev` is tested 548to `bisect_nr`, the expected number of commits to be tested if 549`bisect_rev` turns out to be good to `bisect_good`, the expected 550number of commits to be tested if `bisect_rev` turns out to be bad to 551`bisect_bad`, and the number of commits we are bisecting right now to 552`bisect_all`. 553 554--bisect-all:: 555 556This outputs all the commit objects between the included and excluded 557commits, ordered by their distance to the included and excluded 558commits. Refs in `refs/bisect/` are not used. The farthest 559from them is displayed first. (This is the only one displayed by 560`--bisect`.) 561+ 562This is useful because it makes it easy to choose a good commit to 563test when you want to avoid to test some of them for some reason (they 564may not compile for example). 565+ 566This option can be used along with `--bisect-vars`, in this case, 567after all the sorted commit objects, there will be the same text as if 568`--bisect-vars` had been used alone. 569endif::git-rev-list[] 570 571 572Commit Ordering 573~~~~~~~~~~~~~~~ 574 575By default, the commits are shown in reverse chronological order. 576 577--topo-order:: 578 579 This option makes them appear in topological order (i.e. 580 descendant commits are shown before their parents). 581 582--date-order:: 583 584 This option is similar to '--topo-order' in the sense that no 585 parent comes before all of its children, but otherwise things 586 are still ordered in the commit timestamp order. 587 588--reverse:: 589 590 Output the commits in reverse order. 591 Cannot be combined with '\--walk-reflogs'. 592 593Object Traversal 594~~~~~~~~~~~~~~~~ 595 596These options are mostly targeted for packing of git repositories. 597 598--objects:: 599 600 Print the object IDs of any object referenced by the listed 601 commits. '--objects foo ^bar' thus means "send me 602 all object IDs which I need to download if I have the commit 603 object 'bar', but not 'foo'". 604 605--objects-edge:: 606 607 Similar to '--objects', but also print the IDs of excluded 608 commits prefixed with a "-" character. This is used by 609 linkgit:git-pack-objects[1] to build "thin" pack, which records 610 objects in deltified form based on objects contained in these 611 excluded commits to reduce network traffic. 612 613--unpacked:: 614 615 Only useful with '--objects'; print the object IDs that are not 616 in packs. 617 618--no-walk:: 619 620 Only show the given revs, but do not traverse their ancestors. 621 622--do-walk:: 623 624 Overrides a previous --no-walk. 625 626Commit Formatting 627~~~~~~~~~~~~~~~~~ 628 629ifdef::git-rev-list[] 630Using these options, linkgit:git-rev-list[1] will act similar to the 631more specialized family of commit log tools: linkgit:git-log[1], 632linkgit:git-show[1], and linkgit:git-whatchanged[1] 633endif::git-rev-list[] 634 635include::pretty-options.txt[] 636 637--relative-date:: 638 639 Synonym for `--date=relative`. 640 641--date=(relative|local|default|iso|rfc|short|raw):: 642 643 Only takes effect for dates shown in human-readable format, such 644 as when using "--pretty". `log.date` config variable sets a default 645 value for log command's --date option. 646+ 647`--date=relative` shows dates relative to the current time, 648e.g. "2 hours ago". 649+ 650`--date=local` shows timestamps in user's local timezone. 651+ 652`--date=iso` (or `--date=iso8601`) shows timestamps in ISO 8601 format. 653+ 654`--date=rfc` (or `--date=rfc2822`) shows timestamps in RFC 2822 655format, often found in E-mail messages. 656+ 657`--date=short` shows only date but not time, in `YYYY-MM-DD` format. 658+ 659`--date=raw` shows the date in the internal raw git format `%s %z` format. 660+ 661`--date=default` shows timestamps in the original timezone 662(either committer's or author's). 663 664ifdef::git-rev-list[] 665--header:: 666 667 Print the contents of the commit in raw-format; each record is 668 separated with a NUL character. 669endif::git-rev-list[] 670 671--parents:: 672 673 Print also the parents of the commit (in the form "commit parent..."). 674 Also enables parent rewriting, see 'History Simplification' below. 675 676--children:: 677 678 Print also the children of the commit (in the form "commit child..."). 679 Also enables parent rewriting, see 'History Simplification' below. 680 681ifdef::git-rev-list[] 682--timestamp:: 683 Print the raw commit timestamp. 684endif::git-rev-list[] 685 686--left-right:: 687 688 Mark which side of a symmetric diff a commit is reachable from. 689 Commits from the left side are prefixed with `<` and those from 690 the right with `>`. If combined with `--boundary`, those 691 commits are prefixed with `-`. 692+ 693For example, if you have this topology: 694+ 695----------------------------------------------------------------------- 696 y---b---b branch B 697 / \ / 698 / . 699 / / \ 700 o---x---a---a branch A 701----------------------------------------------------------------------- 702+ 703you would get an output like this: 704+ 705----------------------------------------------------------------------- 706 $ git rev-list --left-right --boundary --pretty=oneline A...B 707 708 >bbbbbbb... 3rd on b 709 >bbbbbbb... 2nd on b 710 <aaaaaaa... 3rd on a 711 <aaaaaaa... 2nd on a 712 -yyyyyyy... 1st on b 713 -xxxxxxx... 1st on a 714----------------------------------------------------------------------- 715 716--graph:: 717 718 Draw a text-based graphical representation of the commit history 719 on the left hand side of the output. This may cause extra lines 720 to be printed in between commits, in order for the graph history 721 to be drawn properly. 722+ 723This enables parent rewriting, see 'History Simplification' below. 724+ 725This implies the '--topo-order' option by default, but the 726'--date-order' option may also be specified. 727 728ifdef::git-rev-list[] 729--count:: 730 Print a number stating how many commits would have been 731 listed, and suppress all other output. When used together 732 with '--left-right', instead print the counts for left and 733 right commits, separated by a tab. 734endif::git-rev-list[] 735 736 737ifndef::git-rev-list[] 738Diff Formatting 739~~~~~~~~~~~~~~~ 740 741Below are listed options that control the formatting of diff output. 742Some of them are specific to linkgit:git-rev-list[1], however other diff 743options may be given. See linkgit:git-diff-files[1] for more options. 744 745-c:: 746 747 With this option, diff output for a merge commit 748 shows the differences from each of the parents to the merge result 749 simultaneously instead of showing pairwise diff between a parent 750 and the result one at a time. Furthermore, it lists only files 751 which were modified from all parents. 752 753--cc:: 754 755 This flag implies the '-c' options and further compresses the 756 patch output by omitting uninteresting hunks whose contents in 757 the parents have only two variants and the merge result picks 758 one of them without modification. 759 760-m:: 761 762 This flag makes the merge commits show the full diff like 763 regular commits; for each merge parent, a separate log entry 764 and diff is generated. An exception is that only diff against 765 the first parent is shown when '--first-parent' option is given; 766 in that case, the output represents the changes the merge 767 brought _into_ the then-current branch. 768 769-r:: 770 771 Show recursive diffs. 772 773-t:: 774 775 Show the tree objects in the diff output. This implies '-r'. 776 777-s:: 778 Suppress diff output. 779endif::git-rev-list[]