Git
简体中文 ▾ Topics ▾ Latest version ▾ git-rev-list last updated in 2.44.0

名称

git-rev-list 按照时间倒序列出提交对象

概述

git rev-list [<选项>] <提交>…​ [[--] <路径>…​]

描述

Warning

Missing zh_HANS-CN/rev-list-description.txt

See original version for this content.

rev-list 是一个非常必要的Git命令,因为它提供了构建和遍历祖先图的功能。正因如此,它有很多不同的选项,使得它可以被不同的命令使用,如 git bisectgit repack

选项

承诺限制

除了使用描述中解释的特殊符号指定应列出的提交范围,还可以应用额外的提交限制。

Using more options generally further limits the output (e.g. --since=<date1> limits to commits newer than <date1>, and using it with --grep=<pattern> further limits to commits whose log message has a line that matches <pattern>), unless otherwise noted.

请注意,这些都是在提交排序和格式化选项之前应用的,如 --reverse

-<数>
-n <数量>
--max-count=<数量>

限制输出的提交数量。

--skip=<数量>

在开始显示提交输出之前,跳过’数’的提交。

--since=<日期>
--after=<日期>

显示比某一特定日期更近的提交。

--since-as-filter=<日期>

显示所有比指定日期更近的提交。这将访问该范围内的所有提交,而不是停在第一个比指定日期更早的提交。

--until=<日期>
--before=<日期>

显示超过特定日期的提交。

--max-age=<时间戳>
--min-age=<时间戳>

将提交的结果限制在指定的时间范围内。

--author=<模式>
--committer=<模式>

Limit the commits output to ones with author/committer header lines that match the specified pattern (regular expression). With more than one --author=<pattern>, commits whose author matches any of the given patterns are chosen (similarly for multiple --committer=<pattern>).

--grep-reflog=<模式>

Limit the commits output to ones with reflog entries that match the specified pattern (regular expression). With more than one --grep-reflog, commits whose reflog message matches any of the given patterns are chosen. It is an error to use this option unless --walk-reflogs is in use.

--grep=<模式>

Limit the commits output to ones with a log message that matches the specified pattern (regular expression). With more than one --grep=<pattern>, commits whose message matches any of the given patterns are chosen (but see --all-match).

--all-match

将输出的提交限制在符合所有给定`--grep`的提交,而不是至少符合一个的提交。

--invert-grep

限定输出的提交信息与 `--grep=<模式>`指定的模式不匹配。

-i
--regexp-ignore-case

匹配正则表达式的限制模式,不考虑字母大小写。

--basic-regexp

将限制性模式视为基本的正则表达式;这是默认的。

-E
--extended-regexp

将限制性模式视为扩展的正则表达式,而不是默认的基本正则表达式。

-F
--fixed-strings

将限制性模式视为固定字符串(不要将模式解释为正则表达式)。

-P
--perl-regexp

将限制性模式视为与Perl兼容的正则表达式。

对这些类型的正则表达式的支持是一个可选的编译时依赖。如果Git在编译时没有对它们的支持,提供这个选项将导致它死亡。

--remove-empty

当一个给定的路径从树上消失时停止。

--merges

只打印合并后的提交。这与`--min-parents=2`完全相同。

--no-merges

不打印有一个以上父级的提交。这与`--max-parents=1`完全相同。

--min-parents=<数量>
--max-parents=<数量>
--no-min-parents
--no-max-parents

Show only commits which have at least (or at most) that many parent commits. In particular, --max-parents=1 is the same as --no-merges, --min-parents=2 is the same as --merges. --max-parents=0 gives all root commits and --min-parents=3 all octopus merges.

--no-min-parents and --no-max-parents reset these limits (to no limit) again. Equivalent forms are --min-parents=0 (any commit has 0 or more parents) and --max-parents=-1 (negative numbers denote no upper limit).

--first-parent

When finding commits to include, follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.

--exclude-first-parent-only

When finding commits to exclude (with a ^), follow only the first parent commit upon seeing a merge commit. This can be used to find the set of changes in a topic branch from the point where it diverged from the remote branch, given that arbitrary merges can be valid topic branch changes.

--not

Reverses the meaning of the ^ prefix (or lack thereof) for all following revision specifiers, up to the next --not. When used on the command line before --stdin, the revisions passed through stdin will not be affected by it. Conversely, when passed via standard input, the revisions passed on the command line will not be affected by it.

--all

假设`refs/‘中的所有参考文献,连同`HEAD`一起,在命令行中被列为’<commit>'。

--branches[=<模式>]

假设`refs/heads`中的所有 refs 在命令行中被列为 <commit>。如果给出了'<pattern>',将分支限制在与给定的shell glob相匹配的分支。如果pattern缺少'?*'或'[,则末尾的/*'是暗示的。

--tags[=<模式>]

假设`refs/tags`中的所有参考文献在命令行中被列为'<commit>'。如果给出了'<pattern>',将标签限制在与给定的shell glob相匹配的标签。如果pattern缺少'?*'或'[,则暗示最后的/*'。

--remotes[=<模式>]

Pretend as if all the refs in refs/remotes are listed on the command line as <commit>. If <pattern> is given, limit remote-tracking branches to ones matching given shell glob. If pattern lacks ?, *, or [, /* at the end is implied.

--glob=<通配符模式>

假设所有与shell glob <glob-pattern>相匹配的refs在命令行中被列为<commit>'。前面的’refs/,如果缺少的话会自动预加。如果模式中缺少?*'或'[,则在结尾处隐含/*'。

--exclude=<通配符模式>

不包括匹配"<glob-pattern>"的参考文献,否则下一个`--all`、--branches--tags--remotes`或--glob`会考虑这些参考文献。重复这个选项可以累积排除模式,直到下一个`----all`、---branches---tags---remotes`或---glob`选项(其他选项或参数不清除累积模式)。

当应用于 --branches--tags--remotes 时,所给出的模式不应以 refs/headsrefs/tagsrefs/remotes 开头;当应用于 --glob--all 选项时,必须以 refs/ 开头。如果要使用尾部的 /*,则必须明确给出。

--exclude-hidden=[fetch|receive|uploadpack]

通过查阅相应的 fetch.hideRefsreceive.hideRefsuploadpack.hideRefs 配置和 transfer.hideRefs 配置(参见 git-config[1]),不要包含会被 git-fetchgit-receive-packgit-upload-pack 隐藏的引用。该选项会影响下一个伪引用选项 --all--glob,并在处理后清除。

--reflog

假设reflogs提到的所有对象都在命令行中被列为`<commit>`。

--alternate-refs

Pretend as if all objects mentioned as ref tips of alternate repositories were listed on the command line. An alternate repository is any repository whose object directory is specified in objects/info/alternates. The set of included objects may be modified by core.alternateRefsCommand, etc. See git-config[1].

--single-worktree

By default, all working trees will be examined by the following options when there are more than one (see git-worktree[1]): --all, --reflog and --indexed-objects. This option forces them to examine the current working tree only.

--ignore-missing

在看到输入中无效的对象名称时,假装没有给出坏的输入。

--stdin

除从命令行获取参数外,还可从标准输入读取参数。它接受提交和伪选项,如 --all--glob=。当看到 -- 分隔符时,下面的输入将被视为路径并用于限制结果。通过标准输入读取的 --not 等标志只适用于以相同方式传递的参数,不会影响后续的命令行参数。

--quiet

Don’t print anything to standard output. This form is primarily meant to allow the caller to test the exit status to see if a range of objects is fully connected (or not). It is faster than redirecting stdout to /dev/null as the output does not have to be formatted.

--disk-usage
--disk-usage=human

Suppress normal output; instead, print the sum of the bytes used for on-disk storage by the selected commits or objects. This is equivalent to piping the output into git cat-file --batch-check='%(objectsize:disk)', except that it runs much faster (especially with --use-bitmap-index). See the CAVEATS section in git-cat-file[1] for the limitations of what "on-disk storage" means. With the optional value human, on-disk storage size is shown in human-readable string(e.g. 12.24 Kib, 3.50 Mib).

--cherry-mark

就像`--cherry-pick`(见下文),但用`=标记同等的提交,而不是省略,用+`标记不同等的提交。

--cherry-pick

当提交的集合有对称差异时,省略任何与 "另一边 "的另一个提交相同的提交。

例如,如果你有两个分支,AB,通常的方法是用`--左—​右`列出其中一边的所有提交(见下面关于`--left-right`选项的描述)。然而,它显示的是从另一个分支中偷梁换柱的提交(例如,'3rd on b' 可能是从分支 A 中偷梁换柱的)。有了这个选项,这样的提交对将从输出中排除。

--left-only
--right-only

只列出对称性差异各自一侧的提交,即只列出那些通过 --left-right 标记的 <>

For example, --cherry-pick --right-only A...B omits those commits from B which are in A or are patch-equivalent to a commit in A. In other words, this lists the + commits from git cherry A B. More precisely, --cherry-pick --right-only --no-merges gives the exact list.

--cherry

--right-only --cherry-mark --no-merges`的同义词;有助于将输出限制在我们这边的提交,并标记那些已经应用到分叉历史的另一边的提交,`git log --cherry upstream...mybranch,类似于`git cherry upstream mybranch`。

-g
--walk-reflogs

Instead of walking the commit ancestry chain, walk reflog entries from the most recent one to older ones. When this option is used you cannot specify commits to exclude (that is, ^commit, commit1..commit2, and commit1...commit2 notations cannot be used).

With --pretty format other than oneline and reference (for obvious reasons), this causes the output to have two extra lines of information taken from the reflog. The reflog designator in the output may be shown as ref@{Nth} (where Nth is the reverse-chronological index in the reflog) or as ref@{timestamp} (with the timestamp for that entry), depending on a few rules:

  1. 如果起点被指定为`ref@{Nth}`,显示索引格式。

  2. 如果起点被指定为`ref@{now}`,显示时间戳格式。

  3. 如果两者都没有使用,但在命令行中给出了`--date`,则按照`--date`所要求的格式显示时间戳。

  4. 否则,显示索引格式。

Under --pretty=oneline, the commit message is prefixed with this information on the same line. This option cannot be combined with --reverse. See also git-reflog[1].

在`--pretty=reference`下,这些信息将完全不显示。

--merge

在合并失败后,显示触及有冲突的文件且不存在于所有要合并的头的参考文件。

--boundary

输出排除的边界提交。边界提交的前缀是"-"。

--use-bitmap-index

尝试使用包位图索引(如果有的话)来加快遍历的速度。注意,当使用`--objects` 选项进行遍历时,目录树和 blobs 不会打印出它们的相关路径。

--progress=<头信息>

在考虑对象时在stderr上显示进度报告。`<标题>`文本将在每次进度更新时打印。

简化历史

有时你只对历史的一部分感兴趣,例如修改某个<路径>的提交。但 "历史简化 "有两部分,一部分是选择提交,另一部分是如何做,因为有各种策略来简化历史。

以下选项选择要显示的提交:

<paths>

修改给定<路径>的提交会被选中。

--simplify-by-decoration

被某个分支或标签引用的提交被选中。

请注意,可以显示额外的提交,以提供一个有意义的历史。

以下选项会影响简化的执行方式:

默认模式

将历史简化为解释树的最终状态的最简单的历史。最简单的原因是,如果最终结果相同,它会修剪一些侧枝(即合并具有相同内容的分支)

--show-pulls

包括默认模式下的所有提交,但也包括任何与第一个父分支不相干但与后来的父分支相干的合并提交。这种模式有助于显示 "首次引入 "某个分支的合并提交。

--full-history

与默认模式相同,但不修剪一些历史记录。

--dense

只显示所选的提交,再加上一些才有意义的历史。

--sparse

简化历史中的所有提交都会显示出来。

--simplify-merges

为`--full-history`增加了一个选项,可以从结果的历史中删除一些不必要的合并,因为没有选定的提交对这次合并有贡献。

--ancestry-path[=<提交>]

When given a range of commits to display (e.g. commit1..commit2 or commit2 ^commit1), only display commits in that range that are ancestors of <commit>, descendants of <commit>, or <commit> itself. If no commit is specified, use commit1 (the excluded part of the range) as <commit>. Can be passed multiple times; if so, a commit is included if it is any of the commits given or if it is an ancestor or descendant of one of them.

以下是更详细的解释。

Suppose you specified foo as the <paths>. We shall call commits that modify foo !TREESAME, and the rest TREESAME. (In a diff filtered for foo, they look different and equal, respectively.)

In the following, we will always refer to the same example history to illustrate the differences between simplification settings. We assume that you are filtering for a file foo in this commit graph:

	  .-A---M---N---O---P---Q
	 /     /   /   /   /   /
	I     B   C   D   E   Y
	 \   /   /   /   /   /
	  `-------------'   X

The horizontal line of history A---Q is taken to be the first parent of each merge. The commits are:

  • ‘I`是初始提交,其中`foo`存在,内容是`asdf’,文件`quux`存在,内容是`quux'。初始提交与空树比较,所以`I`是!`TREESAME。

  • 在`A`中,‘foo`只包含`foo’'。

  • B contains the same change as A. Its merge M is trivial and hence TREESAME to all parents.

  • C`没有改变`foo,但是它的合并`N`将其改为`foobar'',所以它与任何父类都不存在TREESAME。

  • ‘D`将`foo`设置为`baz’。它的合并项`O`将`N`和`D`的字符串合并为`foobarbaz';也就是说,它与任何父类都不是TREESAME。

  • ‘E`将`quux`改为`xyzzy’,其合并的`P`将这些字符串合并为`quux xyzzy'。`P’与`O’的关系是TREESAME,但与`E’不是。

  • X`是一个独立的根提交,添加了一个新文件`sideY`修改了它。`Y`与`X`同为TREESAME。它的合并文件`Q`在`P`上添加了`side,`Q`与`P`是同源,但与`Y`不是同源。

rev-list`在历史中倒退,根据是否使用--full-history`和/或父代重写(通过`--parents`或`--children`),包括或排除提交。以下设置是可用的。

默认模式

Commits are included if they are not TREESAME to any parent (though this can be changed, see --sparse below). If the commit was a merge, and it was TREESAME to one parent, follow only that parent. (Even if there are several TREESAME parents, follow only one of them.) Otherwise, follow all parents.

这将实现:

	  .-A---N---O
	 /     /   /
	I---------D

Note how the rule to only follow the TREESAME parent, if one is available, removed B from consideration entirely. C was considered via N, but is TREESAME. Root commits are compared to an empty tree, so I is !TREESAME.

父/子关系只有在使用 --parents 选项的情况下才能看到,但这并不影响在默认模式下选择的提交,所以我们显示了父行。

--full-history 无父级重写的完整历史记录

This mode differs from the default in one point: always follow all parents of a merge, even if it is TREESAME to one of them. Even if more than one side of the merge has commits that are included, this does not imply that the merge itself is! In the example, we get

	I  A  B  N  D  O  P  Q

M was excluded because it is TREESAME to both parents. E, C and B were all walked, but only B was !TREESAME, so the others do not appear.

请注意,如果没有父子重写,其实是不可能谈论提交之间的父子关系的,所以我们显示它们是不相连的。

--full-history 带父级重写功能的全历史记录

普通的提交只有当它们是!TREESAME时才会被包括在内(尽管这一点可以改变,见下面的`--sparse`)。

Merges are always included. However, their parent list is rewritten: Along each parent, prune away commits that are not included themselves. This results in

	  .-A---M---N---O---P---Q
	 /     /   /   /   /
	I     B   /   D   /
	 \   /   /   /   /
	  `-------------'

Compare to --full-history without rewriting above. Note that E was pruned away because it is TREESAME, but the parent list of P was rewritten to contain E's parent I. The same happened for C and N, and X, Y and Q.

除了上述设置外,你还可以改变 TRESAME 是否会影响收录:

--dense

如果不与任何父类有TREESAME关系,则包括走过的承诺。

--sparse

所有走过的提交都包括在内。

请注意,如果没有`--full-history`,这仍然可以简化合并:如果父代之一是TREESAME,我们只跟随这个父代,所以合并的其他方面永远不会被走。

--simplify-merges

首先,按照`--full-history`与父级改写的相同方式建立一个历史图(见上文)。

然后根据以下规则将每个提交的 C 简化为最终历史中的替换 C

  • 将 "C "设为 "C"。

  • Replace each parent P of C' with its simplification P'. In the process, drop parents that are ancestors of other parents or that are root commits TREESAME to an empty tree, and remove duplicates, but take care to never drop all parents that we are TREESAME to.

  • If after this parent rewriting, C' is a root or merge commit (has zero or >1 parents), a boundary commit, or !TREESAME, it remains. Otherwise, it is replaced with its only parent.

The effect of this is best shown by way of comparing to --full-history with parent rewriting. The example turns into:

	  .-A---M---N---O
	 /     /       /
	I     B       D
	 \   /       /
	  `---------'

注意 NPQ--full-history 的主要区别:

  • N's parent list had I removed, because it is an ancestor of the other parent M. Still, N remained because it is !TREESAME.

  • P's parent list similarly had I removed. P was then removed completely, because it had one parent and is TREESAME.

  • Q`的父列表中有`Y`简化为`X。然后`X`被删除,因为它是一个TREESAME根。然后`Q`被完全删除,因为它有一个父级,是TREESAME。

还有一种简化模式可用:

--ancestry-path[=<提交>]

将显示的提交限制在<提交>的祖先,或<提交>的后代,或<提交>本身。

作为一个用例,请考虑以下提交历史:

	    D---E-------F
	   /     \       \
	  B---C---G---H---I---J
	 /                     \
	A-------K---------------L--M

有规律的 "D…​M "会计算出作为`M`的祖先的提交集合,但不包括作为`D`的祖先的提交。这对了解`M’的历史在`D’之后发生了什么很有用,也就是说`M’有什么东西是`D’没有的'。这个例子中的结果是所有的提交,除了`A`和`B`(当然还有`D`本身)。

When we want to find out what commits in M are contaminated with the bug introduced by D and need fixing, however, we might want to view only the subset of D..M that are actually descendants of D, i.e. excluding C and K. This is exactly what the --ancestry-path option does. Applied to the D..M range, it results in:

		E-------F
		 \       \
		  G---H---I---J
			       \
				L--M

我们也可以用`--ancestry-path=D`来代替`--ancestry-path`,这在应用于’D…​M’范围时意思相同,只是更加明确。

If we instead are interested in a given topic within this range, and all commits affected by that topic, we may only want to view the subset of D..M which contain that topic in their ancestry path. So, using --ancestry-path=H D..M for example would result in:

		E
		 \
		  G---H---I---J
			       \
				L--M

而`--ancestry-path=K D…​M`会形成以下结果

		K---------------L--M

在讨论另一个选项,`--show-pulls`之前,我们需要创建一个新的历史实例。

用户在查看简化的提交历史时经常遇到的一个问题是,他们知道的对某个文件的修改提交并没有出现在该文件的简史中。让我们演示一个新的例子,并说明`--full-history`和`--simplify-merges`等选项在这种情况下是如何工作的:

	  .-A---M-----C--N---O---P
	 /     / \  \  \/   /   /
	I     B   \  R-'`-Z'   /
	 \   /     \/         /
	  \ /      /\        /
	   `---X--'  `---Y--'

For this example, suppose I created file.txt which was modified by A, B, and X in different ways. The single-parent commits C, Z, and Y do not change file.txt. The merge commit M was created by resolving the merge conflict to include both changes from A and B and hence is not TREESAME to either. The merge commit R, however, was created by ignoring the contents of file.txt at M and taking only the contents of file.txt at X. Hence, R is TREESAME to X but not M. Finally, the natural merge resolution to create N is to take the contents of file.txt at R, so N is TREESAME to R but not C. The merge commits O and P are TREESAME to their first parents, but not to their second parents, Z and Y respectively.

当使用默认模式时,`N’和`R`都有一个TREESAME父级,所以这些边被展示出来,其他边被忽略。由此产生的历史图是:

	I---X

当使用 --full-history 选项时,Git 会行走每条边。这将发现提交 AB 以及合并 M,但也将揭示合并提交 OP 。通过父级改写,得到的图是:

	  .-A---M--------N---O---P
	 /     / \  \  \/   /   /
	I     B   \  R-'`--'   /
	 \   /     \/         /
	  \ /      /\        /
	   `---X--'  `------'

这里,合并提交 OP 带来了额外的输出,因为它们实际上并没有对 file.txt 做出改变。他们只是合并了一个基于 file.txt 旧版本的主题。这是在使用工作流程的仓库中常见的问题,在工作流程中,许多贡献者并行工作,并沿着一个主干合并他们的主题分支:不相关的合并出现在 --full-history 选项结果中。

当使用`--simplify-merges`选项时,提交的 OP 从结果中消失。这是因为 OP 重写的第二父本可以从它们的第一父本到达。这些边被移除,然后这些提交看起来就像与它们的父类一样的单亲提交。这也发生在提交 N 上,导致历史视图如下:

	  .-A---M--.
	 /     /    \
	I     B      R
	 \   /      /
	  \ /      /
	   `---X--'

在这个视图中,我们看到了所有来自`A`,B`和`X`的重要单亲变化。我们还可以看到仔细解决的合并`M`和不那么仔细解决的合并`R。这些信息通常足以确定为什么`A`和`B`的提交在默认视图中从历史中 "消失 "了。然而,这种方法也有一些问题。

第一个问题是性能。与之前的任何选项不同,--simplify-merges 选项需要在返回一个结果之前走完整个提交历史。这可能使该选项难以用于非常大的仓库。

第二个问题是审计的问题。当许多贡献者在同一个版本库中工作时,哪些合并提交将一个变化引入到一个重要的分支是很重要的。上面有问题的合并`R`不可能是用来合并到一个重要分支的合并提交。相反,`N’是用来将`R’和`X’合并到重要分支的。这个提交可能有关于为什么`X’会覆盖`A’和`B’的修改的信息,在其提交信息中。

--show-pulls

除了在默认历史中显示的提交之外,还要显示每一个与第一个父本不相同但与后来的父本相同的合并提交。

当一个合并提交被 --show-pulls 选项包含时,该合并被视为从另一个分支 “拉取” 来的修改。在这个例子中使用 --show-pulls 选项时(没有其他选项),得到的图是:

	I---X---R---N

这里,合并后的提交`R`和`N`被包括在内,因为它们分别将提交`X`和`R`拉到了基础分支。这些合并是`A`和`B`的提交没有出现在默认历史中的原因。

--show-pulls--simplify-merges 选项配对时,该图包括所有必要的信息:

	  .-A---M--.   N
	 /     /    \ /
	I     B      R
	 \   /      /
	  \ /      /
	   `---X--'

请注意,由于`M`可以从`R`到达,从`N`到`M`的边被简化掉了。然而,`N`仍然作为一个重要的提交出现在历史中,因为它把`R`的修改 "拉 "进了主分支。

The --simplify-by-decoration option allows you to view only the big picture of the topology of the history, by omitting commits that are not referenced by tags. Commits are marked as !TREESAME (in other words, kept after history simplification rules described above) if (1) they are referenced by tags, or (2) they change the contents of the paths given on the command line. All other commits are marked as TREESAME (subject to be simplified away).

剖腹产助手

--bisect

将输出限制在一个提交对象上,该对象大致在包含和排除的提交之间。请注意,坏的分界参考`refs/bisect/bad`会被添加到包含的提交中(如果它存在的话),好的分界参考`refs/bisect/good-*`会被添加到排除的提交中(如果它们存在的话)。因此,假设`refs/bisect/`中没有参考文献,如果

	$ git rev-list --bisect foo ^bar ^baz

输出 midpoint,即两个命令的输出

	$ git rev-list foo ^midpoint
	$ git rev-list midpoint ^bar ^baz

would be of roughly the same length. Finding the change which introduces a regression is thus reduced to a binary search: repeatedly generate and test new 'midpoint’s until the commit chain is of length one.

--bisect-vars

这与`--bisect`的计算方法相同,只是不使用`refs/bisect/中的参考文献,而且输出的文本可以被shell评估。这几行将把中点修订的名称分配给变量`bisect_rev,并把`bisect_rev`测试后的预期提交数分配给`bisect_nr`。如果`bisect_rev’结果是好的,预计测试的提交数量为`bisect_good',如果`bisect_rev’结果是坏的,预计测试的提交数量为`bisect_bad',以及我们现在正在分叉的提交数量为`bisect_all'。

--bisect-all

这将输出包含的提交和排除的提交之间的所有提交对象,按照它们与包含的提交和排除的提交的距离排序。refs/bisect/`中的引用不被使用。离它们最远的会先显示出来。这也是 `--bisect 选项唯一显示的对象。)

这很有用,因为当你因为某些原因想避免测试某些提交时(例如,它们可能无法编译),可以很容易地选择一个好的提交来测试。

这个选项可以和`--bisect-vars`一起使用,在这种情况下,在所有排序的提交对象之后,会有和`--bisect-vars`单独使用一样的文本。

承诺订购

默认情况下,提交的内容是按时间顺序倒序显示的。

--date-order

在显示所有子代之前不显示父代,否则按提交时间戳顺序显示提交。

--author-date-order

在显示所有子代之前不显示父代,否则按作者时间戳顺序显示提交。

--topo-order

在显示所有子代之前不显示父代,并避免显示多行历史交错的提交。

例如,在这样的一个提交历史中:

    ---1----2----4----7
	\	       \
	 3----5----6----8---

其中数字表示提交时间戳的顺序,git rev-list`和带有--date-order`的朋友显示提交的时间戳顺序。8 7 6 5 4 3 2 1.

如果使用`--topo-order`,它们会显示8 6 5 3 7 4 2 1(或8 7 4 2 6 5 3 1);一些较早的提交会显示在较新的提交之前,以避免显示两个平行开发轨道的提交混在一起。

--reverse

以相反的顺序输出选择显示的提交(见上面的提交限制部分)。不能与`--walk-reflogs`结合使用。

对象遍历

这些选项主要是针对Git存储库的打包。

--objects

Print the object IDs of any object referenced by the listed commits. --objects foo ^bar thus means “send me all object IDs which I need to download if I have the commit object bar but not foo”. See also --object-names below.

--in-commit-order

按照提交的顺序打印树和blob的id。树和blob的id会在它们第一次被提交者引用后打印。

--objects-edge

Similar to --objects, but also print the IDs of excluded commits prefixed with a “-” character. This is used by git-pack-objects[1] to build a “thin” pack, which records objects in deltified form based on objects contained in these excluded commits to reduce network traffic.

--objects-edge-aggressive

Similar to --objects-edge, but it tries harder to find excluded commits at the cost of increased time. This is used instead of --objects-edge to build “thin” packs for shallow repositories.

--indexed-objects

Pretend as if all trees and blobs used by the index are listed on the command line. Note that you probably want to use --objects, too.

--unpacked

只对 ---objects 有用;打印不在包中的对象 ID。

--object-names

只对 --objects 有用;打印找到的对象ID的名称。这是默认的行为。注意,每个对象的 "名字" 是模糊的,主要是作为打包对象的提示。特别是:标签、树和二进制文件的名字不作区分;路径名称可以被修改以删除换行;如果一个对象会以不同的名字出现多次,则只显示一个名字。

--no-object-names

只对 --objects 有用;不打印找到的对象 ID 的名称。这与 --object-names 相反。这个标志允许输出更容易被 git-cat-file[1] 等命令解析。

--filter=<过滤器定义>

Only useful with one of the --objects*; omits objects (usually blobs) from the list of printed objects. The <filter-spec> may be one of the following:

'--filter=blob:none’的形式可以省略所有的blob。

The form --filter=blob:limit=<n>[kmg] omits blobs of size at least n bytes or units. n may be zero. The suffixes k, m, and g can be used to name units in KiB, MiB, or GiB. For example, blob:limit=1k is the same as blob:limit=1024.

'--filter=object:type=(tag|commit|tree|blob)'的形式会省略所有不属于请求类型的对象。

表格 --filter=sparse:oid=<blob-ish> 使用 blob(或 blob 表达式)<blob-ish> 中包含的稀疏检出规范,以省略在请求的引用上进行稀疏检出时不需要的 blob。

--filter=tree:<深度> 的形式省略了所有从根树开始深度 >=<深度>(如果一个对象在所穿越的提交中位于多个深度,则为最小深度)的blobs和目录树。<深度>=0 将不包括任何目录树或 blobs,除非在命令行中明确包括(或使用 --stdin 选项时的标准输入)。<深度>=1 将只包括由 <提交> 或明确指定的对象所能到达的提交直接引用的目录树和 blobs。<深度>=2 与 <深度>=1 类似,同时也包括从明确给出的提交或目录树中移出的多一级的目录树和 blobs。

注意,出于安全原因,想要从文件系统上的任意路径读取的'--filter=sparse:path=<path>'形式已经被放弃了。

可以指定多个'--filter=' 标志来组合过滤器。只有那些被每个过滤器接受的对象才会被包括在内。

The form --filter=combine:<filter1>+<filter2>+…​<filterN> can also be used to combined several filters, but this is harder than just repeating the --filter flag and is usually not necessary. Filters are joined by + and individual filters are %-encoded (i.e. URL-encoded). Besides the + and % characters, the following characters are reserved and also must be encoded: ~!@#$^&*()[]{}\;",<>?'` as well as all characters with ASCII code <= 0x20, which includes space and newline.

其他任意的字符也可以被编码。例如,'combined:tree:3+blob:none’和’combined:tree%3A3+blob%3Anone’是等同的。

--no-filter

关掉之前的任何`--filter=`参数。

--filter-provided-objects

过滤明确提供的对象的列表,否则,即使它们不符合任何过滤器,也会被打印出来。只对`--filter=`有用。

--filter-print-omitted

Only useful with --filter=; prints a list of the objects omitted by the filter. Object IDs are prefixed with a “~” character.

--missing=<缺失行为>

A debug option to help with future "partial clone" development. This option specifies how missing objects are handled.

The form --missing=error requests that rev-list stop with an error if a missing object is encountered. This is the default action.

The form --missing=allow-any will allow object traversal to continue if a missing object is encountered. Missing objects will silently be omitted from the results.

The form --missing=allow-promisor is like allow-any, but will only allow object traversal to continue for EXPECTED promisor missing objects. Unexpected missing objects will raise an error.

The form --missing=print is like allow-any, but will also print a list of the missing objects. Object IDs are prefixed with a “?” character.

--exclude-promisor-objects

(For internal use only.) Prefilter object traversal at promisor boundary. This is used with partial clone. This is stronger than --missing=allow-promisor because it limits the traversal, rather than just silencing errors about missing objects.

--no-walk[=(sorted|unsorted)]

Only show the given commits, but do not traverse their ancestors. This has no effect if a range is specified. If the argument unsorted is given, the commits are shown in the order they were given on the command line. Otherwise (if sorted or no argument was given), the commits are shown in reverse chronological order by commit time. Cannot be combined with --graph.

--do-walk

覆盖之前的 --no-walk

承诺格式化

使用这些选项,git-rev-list[1] 的作用类似于更专业的提交日志工具系列:git-log[1],linkgit:git-show[1],和linkgit:git-whatchanged[1]

--pretty[=<format>]
--format=<format>

以指定的格式打印提交日志的内容,其中'<format>'可以是’oneline'、shortmediumfullfullerreferenceemailrawformat:<string>'和’tformat:<string>'之一。 当<format>'不是上述任何一种,并且其中有'%placeholder’时,它的作用就像给出'--pretty=tformat:<format>'一样。

参见 "PRETTY FORMATS "部分,了解每种格式的一些额外细节。 当'=<格式>'部分被省略时,它默认为’中等'。

注意:你可以在版本库配置中指定默认的漂亮格式(见git-config[1])。

--abbrev-commit

不要显示完整的40字节的十六进制提交对象名称,而是显示一个前缀,以唯一的方式命名该对象。 "--abbrev=<n>"选项可以用来指定前缀的最小长度(如果显示的话,它也会修改diff输出)。

这应该使"--pretty=oneline "对于使用80列终端的人来说更容易阅读。

--no-abbrev-commit

显示完整的40字节十六进制的提交对象名称。这否定了`--abbrev-commit`,无论是明确的还是由其他选项如"--oneline "暗示的。它还覆盖了`log.abbrevCommit`变量。

--oneline

这是"--pretty=oneline --abbrev-commit "的简写,一起使用。

--encoding=<encoding>

提交对象在其编码头中记录了日志信息所使用的编码;这个选项可以用来告诉命令以用户喜欢的编码来重新编码提交日志信息。 对于非管道命令,默认为UTF-8。请注意,如果一个对象声称是以`X`编码的,而我们是以`X`输出的,我们将逐字输出该对象;这意味着原始提交中的无效序列可能会被复制到输出中。

--expand-tabs=<n>
--expand-tabs
--no-expand-tabs

在输出中显示之前,在日志信息中进行标签扩展(用足够的空格替换每个标签,以填充到下一个显示列的'<n>'的倍数)。 --expand-tabs`是--expand-tabs=8`的简写,--no-expand-tabs`是--expand-tabs=0`的简写,它禁止标签扩展。

默认情况下,标签会以漂亮的格式展开,将日志信息缩进4个空格(即 "中",这是默认的,"全",和 "更全")。

--show-signature

通过将签名传递给 gpg --verify 来检查已签名的提交对象的有效性,并显示输出。

--relative-date

`--date=relative`的同义词。

--date=<格式>

只对以人类可读格式显示的日期生效,例如使用`--pretty`时。log.date`配置变量为日志命令的--date`选项设置默认值。默认情况下,日期显示在原始时区(提交者或作者的时区)。如果`-local`被附加到格式中(例如,iso-local),就会使用用户的本地时区。

--date=relative`显示相对于当前时间的日期,例如:`2小时前''。--local`选项对`--date=relative`没有影响。

--date=local`是--date=default-local`的一个别名。

--date=iso (or --date=iso8601) shows timestamps in a ISO 8601-like format. The differences to the strict ISO 8601 format are:

  • 用空格代替`T`日期/时间分隔符

  • 时间和时区之间的空间

  • 时区的小时和分钟之间没有冒号

--date=iso-strict(或`--date=iso8601-strict`)显示严格的ISO 8601格式的时间戳。

--date=rfc(或`--date=rfc2822`)显示RFC 2822格式的时间戳,经常出现在电子邮件中。

--date=short`只显示日期,而不是时间,格式为`YYYY-MM-DD

--date=raw shows the date as seconds since the epoch (1970-01-01 00:00:00 UTC), followed by a space, and then the timezone as an offset from UTC (a + or - with four digits; the first two are hours, and the second two are minutes). I.e., as if the timestamp were formatted with strftime("%s %z")). Note that the -local option does not affect the seconds-since-epoch value (which is always measured in UTC), but does switch the accompanying timezone value.

--date=human shows the timezone if the timezone does not match the current time-zone, and doesn’t print the whole date if that matches (ie skip printing year for dates that are "this year", but also skip the whole date itself if it’s in the last few days and we can just say what weekday it was). For older dates the hour and minute is also omitted.

--date=unix shows the date as a Unix epoch timestamp (seconds since 1970). As with --raw, this is always in UTC and therefore -local has no effect.

--date=format:... feeds the format ... to your system strftime, except for %s, %z, and %Z, which are handled internally. Use --date=format:%c to show the date in your system locale’s preferred format. See the strftime manual for a complete list of format placeholders. When using -local, the correct syntax is --date=format-local:....

--date=default is the default format, and is based on ctime(3) output. It shows a single line with three-letter day of the week, three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS" format, followed by 4-digit year, plus timezone information, unless the local time zone is used, e.g. Thu Jan 1 00:00:00 1970 +0000.

--header

以原始格式打印提交的内容;每条记录用NUL字符分隔。

--no-commit-header

Suppress the header line containing "commit" and the object ID printed before the specified format. This has no effect on the built-in formats; only custom formats are affected.

--commit-header

覆盖之前的 --no-commit-header 选项。

--parents

Print also the parents of the commit (in the form "commit parent…​"). Also enables parent rewriting, see History Simplification above.

--children

Print also the children of the commit (in the form "commit child…​"). Also enables parent rewriting, see History Simplification above.

--timestamp

打印原始提交时间戳。

--left-right

Mark which side of a symmetric difference a commit is reachable from. Commits from the left side are prefixed with < and those from the right with >. If combined with --boundary, those commits are prefixed with -.

例如,如果你有这样的拓扑结构:

	     y---b---b  branch B
	    / \ /
	   /   .
	  /   / \
	 o---x---a---a  branch A

你会得到这样的输出:

	$ git rev-list --left-right --boundary --pretty=oneline A...B

	>bbbbbbb... 3rd on b
	>bbbbbbb... 2nd on b
	<aaaaaaa... 3rd on a
	<aaaaaaa... 2nd on a
	-yyyyyyy... 1st on b
	-xxxxxxx... 1st on a
--graph

Draw a text-based graphical representation of the commit history on the left hand side of the output. This may cause extra lines to be printed in between commits, in order for the graph history to be drawn properly. Cannot be combined with --no-walk.

这可以使父代改写,见上面的’历史简化'。

这意味着默认情况下是`--topo-order`选项,但也可以指定`--date-order`选项。

--show-linear-break[=<阻隔>]

如果不使用 --graph,所有的历史分支都会被压扁,这就很难看出两个连续的提交并不属于一个线性分支。在这种情况下,该选项会在它们之间设置一个障碍。如果指定了"<barrier>",就会显示这个字符串,而不是默认的。

--count

Print a number stating how many commits would have been listed, and suppress all other output. When used together with --left-right, instead print the counts for left and right commits, separated by a tab. When used together with --cherry-mark, omit patch equivalent commits from these counts and print the count for equivalent commits separated by a tab.

漂亮的格式

If the commit is a merge, and if the pretty-format is not oneline, email or raw, an additional line is inserted before the Author: line. This line begins with "Merge: " and the hashes of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the direct parent commits if you have limited your view of history: for example, if you are only interested in changes related to a certain directory or file.

有几种内置的格式,你可以通过将 pretty.<名称> 配置选项设置为另一种格式名称或 format: 字符串来定义额外的格式,如下所述(见 git-config[1] )。下面是内置格式的细节:

  • oneline

    <哈希值> <标题行>

    这个设计是为了尽可能的紧凑。

  • short

    承诺<hash>
    作者。<作者>的情况
    <标题行>
  • medium

    commit <哈希值>
    Author: <作者>
    Date:   <提交日期>
    <标题行>
    <完整的提交信息
  • full

    承诺<hash>
    作者。< Author>
    承诺。<committer>(提交者)。
    <标题行>
    <完整的提交信息
  • fuller

    commit <哈希值>
    Author:     <作者>
    AuthorDate: <作者提交日期>
    Commit:     <提交者>
    CommitDate: <提交者提交日期>
    <标题行>
    <完整的提交信息
  • ‘引用’

    <缩写哈希值>(<标题行>,<简短的作者日期>)

    This format is used to refer to another commit in a commit message and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By default, the date is formatted with --date=short unless another --date option is explicitly specified. As with any format: with format placeholders, its output is not affected by other options like --decorate and --walk-reflogs.

  • email

    From <哈希> <日期>
    From: <作者>
    Date: <作者提交日期>
    Subject: [PATCH] <标题行>
    <完整的提交信息
  • mboxrd

    和 "email "一样,但提交信息中以 "From "开头的行(前面有零个或多个">")用">"引出,这样就不会被混淆为开始了一个新的提交。

  • raw

    The raw format shows the entire commit exactly as stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and parents information show the true parent commits, without taking grafts or history simplification into account. Note that this format affects the way commits are displayed, but not the way the diff is shown e.g. with git log --raw. To get full object names in a raw diff format, use --no-abbrev.

  • format:<格式字符串>

    format:<格式字符串 格式允许你指定要显示的信息。它的工作原理有点像 printf 格式,但有一个明显的例外,那就是换行符是 %n 而不是 \n

    例如,format: "The author of %h was %an, %ar%nThe title was >>%s<<%n" 会显示这样的内容:

    fe6e0ee的作者是Junio C Hamano, 23小时前
    标题是 >>t4119: 测试传统diff输入的自动计算-p<n>。

    占位符是:

    • 占位符,可扩展为一个字面字符:

      %n

      换行

      %%

      一个原始的'%'

      %x00

      %x 后跟两个十六进制数字,会被一个包含十六进制数字值的字节替换(在本文档的其余部分,我们称之为 “字面格式化代码”)。

    • 影响后面占位符的格式化的占位符:

      %Cred

      切换颜色为红色

      %Cgreen

      切换颜色为绿色

      %Cblue

      将颜色改为蓝色

      %Creset

      重置颜色

      %C(…​)

      color specification, as described under Values in the "CONFIGURATION FILE" section of git-config[1]. By default, colors are shown only when enabled for log output (by color.diff, color.ui, or --color, and respecting the auto settings of the former if we are going to a terminal). %C(auto,...) is accepted as a historical synonym for the default (e.g., %C(auto,red)). Specifying %C(always,...) will show the colors even when color is not otherwise enabled (though consider just using --color=always to enable color for the whole output, including this format and anything else git might color). auto alone (i.e. %C(auto)) will turn on auto coloring on the next placeholders until the color is switched again.

      %m

      左(<)、右(>)或边界(-)标记

      %w([<w>[,<i1>[,<i2>]]])

      开关包行,就像 git-shortlog[1] 的 -w 选项。

      %<(<N>[,trunc|ltrunc|mtrunc])

      make the next placeholder take at least N column widths, padding spaces on the right if necessary. Optionally truncate (with ellipsis ..) at the left (ltrunc) ..ft, the middle (mtrunc) mi..le, or the end (trunc) rig.., if the output is longer than N columns. Note 1: that truncating only works correctly with N >= 2. Note 2: spaces around the N and M (see below) values are optional. Note 3: Emojis and other wide characters will take two display columns, which may over-run column boundaries. Note 4: decomposed character combining marks may be misplaced at padding boundaries.

      %<|(<M>)

      make the next placeholder take at least until Mth display column, padding spaces on the right if necessary. Use negative M values for column positions measured from the right hand edge of the terminal window.

      %>(<N>), %>|(<M>)

      分别类似于 %<( <N> )%<|( <M> ),但在左侧填充空格

      %>>(<N>), %>>|(<M>)

      分别类似于'%>(<N>)%>|(<M>)',只是如果下一个占位符占用的空间比给定的多,并且其左侧有空格,则使用这些空格

      %><(<N>), %><|(<M>)

      分别类似于'%<( <N> )' 和 %<|( <M> ),但两边都有填充(即文本居中)

    • 占位符,扩展到从提交中提取的信息:

      %H

      提交的哈希值

      %h

      简称提交哈希

      %T

      目录树哈希值

      %t

      简称树形哈希

      %P

      父类哈希值

      %p

      缩写的父母哈希值

      %an

      作者名

      %aN

      作者名(关于 .mailmap,请参见 git-shortlog[1]git-blame[1]

      %ae

      作者电子邮箱

      %aE

      作者电子邮件(关于 .mailmap,请参见 git-shortlog[1]git-blame[1]

      %al

      作者电子邮件的本地部分(@ 符号之前的部分)

      %aL

      尊重 .mailmap 作者的本地部分(参见 %al ),参见 git-shortlog[1]git-blame[1])

      %ad

      作者日期(格式尊重—​date=选项

      %aD

      作者日期,RFC2822风格

      %ar

      作者日期,相对

      %at

      作者日期,UNIX时间戳

      %ai

      作者日期,类似ISO 8601的格式

      %aI

      作者日期,严格的ISO 8601格式

      %as

      作者日期,短格式( YYYY-MM-DD

      %ah

      作者日期,以易读形式呈现(就像 git-rev-list[1]--date=human 选项)

      %cn

      提交者名称

      %cN

      提交者名称(尊重 .mailmap,参见 git-shortlog[1]git-blame[1]

      %ce

      提交者电子邮箱

      %cE

      提交者电子邮箱(尊重 .mailmap,参见 git-shortlog[1]git-blame[1]

      %cl

      提交者电子邮件的本地部分(@ 符号之前的部分)

      %cL

      提交者本地部分(参见'%cl' )尊重 .mailmap, 参见 git-shortlog[1]git-blame[1])

      %cd

      承诺人日期(格式尊重—​date=选项

      %cD

      承诺人日期,RFC2822风格

      %cr

      承诺人日期,相对

      %ct

      提交者日期,UNIX时间戳

      %ci

      承诺人日期,类似ISO 8601的格式

      %cI

      承诺人日期,严格的ISO 8601格式

      %cs

      承诺人日期,短格式( YYYY-MM-DD

      %ch

      提交者的日期,人类风格(就像 git-rev-list[1]--date=human 选项)

      %d

      ref名称,就像git-log[1]的—​decorate选项。

      %D

      没有"("、")"包装的参考文献名称。

      %(decorate[:<选项>])

      自定义装饰的引用名称。decorate 字符串后面可以是冒号和零个或多个以逗号分隔的选项。选项值可能包含字面格式化代码。由于逗号(%x2C)和结尾括号(%x29)在选项语法中的作用,因此必须使用这些代码。

      • prefix=<value>: Shown before the list of ref names. Defaults to " (".

      • suffix=<value>: Shown after the list of ref names. Defaults to ")".

      • separator=<value>: Shown between ref names. Defaults to ", ".

      • point=<值>: 显示在 HEAD 和其指向的分支(如果有)之间。 默认为 " -> "。

      • tag=<值>: 显示在标记名称之前。默认为 "tag: "。

    例如,制作不带包装或标签注释的装饰,并用空格作为分隔符:

    + %(decorate:prefix=,suffix=,tag=,separator= )

    %(describe[:<选项>])

    human-readable name, like git-describe[1]; empty string for undescribable commits. The describe string may be followed by a colon and zero or more comma-separated options. Descriptions can be inconsistent when tags are added or removed at the same time.

    • tags[=<bool-value>]:不仅考虑带注释的标签,还考虑轻量级标签。

    • abbrev=<数量>:不使用缩写对象名称的默认十六进制位数(根据仓库中对象的数量而变化,默认为 7 位),而是使用 <数量> 的位数,或根据需要的位数来组成唯一的对象名称。

    • match=<pattern>:只考虑与给定的`glob(7)`模式匹配的标签,不包括 "refs/tags/"前缀。

    • exclude=<pattern>:不考虑匹配给定`glob(7)`模式的标签,排除 "refs/tags/"前缀。

    %S

    在命令行中给出的提交名称(如 git log --source),只对 git log 起作用

    %e

    编码方式

    %s

    主题

    %f

    经过消毒的主题行,适合于文件名

    %b

    正文

    %B

    原始体(未包装的主题和体)

    %GG

    来自GPG的签名提交的原始验证信息

    %G?

    show "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity, "X" for a good signature that has expired, "Y" for a good signature made by an expired key, "R" for a good signature made by a revoked key, "E" if the signature cannot be checked (e.g. missing key) and "N" for no signature

    %GS

    显示已签名的提交的签名者的名字

    %GK

    显示用于签署已签名的承诺的密钥

    %GF

    显示用于签署已签名提交文件的密钥的指纹

    %GP

    显示主键的指纹,该主键的子键被用来签署一个已签署的提交

    %GT

    显示用于签署已签名的承诺的密钥的信任级别

    %gD

    reflog选择器,例如,refs/stash@{1}`或`refs/stash@{2分钟前};其格式遵循`-g`选项的规则。@'前面的部分是命令行上给出的参考文献名称(所以`git log -g refs/heads/master`会产生`refs/heads/master@{0})。

    %gd

    简化的 reflog 选择器;与 %gD 相同,但 refname 部分被缩短以利于人类阅读(因此 refs/heads/master 变成了 master)。

    %gn

    记录身份名称

    %gN

    引用日志身份名称(尊重 .mailmap,参见 git-shortlog[1]git-blame[1]

    %ge

    重新记录身份邮件

    %gE

    引用日志身份电子邮箱(尊重 .mailmap,参见 git-shortlog[1]git-blame[1]

    %gs

    记录主题

    %(trailers[:<选项>])

    显示由 git-interpret-trailers[1] 解释的正文的为主。trailers 字符串后面可以有冒号和零个或多个逗号分隔的选项。 如果任何选项被多次提供,则最后出现的选项获胜。

    • key=<key>: only show trailers with specified <key>. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are shown. This option automatically enables the only option so that non-trailer lines in the trailer block are hidden. If that is not desired it can be disabled with only=false. E.g., %(trailers:key=Reviewed-by) shows trailer lines with key Reviewed-by.

    • only[=<布尔值>] :选择是否应该包括来自尾注块的非尾注行。

    • separator=<切片>:指定插入在尾注行之间的分隔符。如果不使用该选项,则每行以换行符结束。字符串 <切片> 可以包含上述字面格式化代码。要使用逗号作为分隔符,必须使用 %x2C,否则会被解析为下一个选项。例如,%(trailer:key=Ticket,separator=%x2C ) 显示所有关键字为 "Ticket" 的尾注行,并用逗号和空格分隔。

    • unfold[=<布尔值>]:使它的行为就像 interpret-trailer 的 --unfold 选项被给出一样。例如,`%(trailers:only,unfold=true)`会展开并显示所有的尾注行。

    • keyonly[=<布尔值>]:只显示尾注的关键部分。

    • valueonly[=<布尔值>]:只显示尾注的值部分。

    • key_value_separator=<切片>:指定在尾注行之间插入一个分隔符。当这个选项没有给出时,每个尾注的键值对都用 ": " 分开。 否则,它的语义与上面的 separator=<切片> 相同。

Note
一些占位符可能取决于给修订版遍历引擎的其他选项。例如,%g* reflog选项将插入一个空字符串,除非我们正在遍历reflog条目(例如,通过`git log -g`)。%d`和%D`占位符将使用 "短 "装饰格式,如果`--decorate`没有在命令行上提供。

布尔选项接受一个可选的值`[=<布尔值>]。`true, false, on, `off`等值都可以接受。参见git-config[1]中 “示例” 的 “布尔” 子章节。如果一个布尔选项没有给出值,它就被启用。

如果你在占位符的'%后面加了一个`+(加号),当且仅当占位符扩展为一个非空字符串时,在扩展前会立即插入换行符。

如果你在占位符的'%后面加了一个`-(减号),如果且仅当占位符扩展为空字符串时,紧接着扩展前的所有连续换行将被删除。

如果你在占位符的'%'后面加了一个``(空格),当且仅当占位符扩展到一个非空字符串时,空格就会紧接着插入扩展。

  • t格式:

    The tformat: format works exactly like format:, except that it provides "terminator" semantics instead of "separator" semantics. In other words, each commit has the message terminator character (usually a newline) appended, rather than a separator placed between entries. This means that the final entry of a single-line format will be properly terminated with a new line, just as the "oneline" format does. For example:

    $ git log -2 --pretty=format:%h 4da45bef \
      | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
    4da45be
    7134973 -- NO NEWLINE
    
    $ git log -2 --pretty=tformat:%h 4da45bef \
      | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
    4da45be
    7134973

    In addition, any unrecognized string that has a % in it is interpreted as if it has tformat: in front of it. For example, these two are equivalent:

    $ git log -2 --pretty=tformat:%h 4da45bef
    $ git log -2 --pretty=%h 4da45bef

实例

  • 打印可从当前分支访问的提交列表。

    git rev-list HEAD
  • 打印该分支上但上游分支中没有的提交列表。

    git rev-list @{上游仓库}..HEAD
  • 将提交格式化为作者和提交信息(另见上层命令 git-log[1])。

    git rev-list --format=medium HEAD
  • 格式化提交及其差异(另请参阅上层命令 git-log[1],它可以在单个进程中完成此操作)。

    git rev-list HEAD |
    git diff-tree --stdin --format=medium -p
  • 打印当前分支中触及 Documentation 目录中任何文件的提交列表。

    git rev-list HEAD -- Documentation/
  • 打印您在过去一年中在任何分支、标记或其他引用上提交的提交列表。

    git rev-list --author=you@example.com --since=1.year.ago --all
  • 打印可从当前分支到达的对象列表(即所有提交及其包含的 blobs 和目录树)。

    git rev-list --objects HEAD
  • 比较所有可到达对象的磁盘大小、可从引用日志到达的对象的磁盘大小以及打包后的总大小。这可以告诉你运行 git repack -ad 是否会减少仓库的大小(通过丢弃无法访问的对象),以及过期的引用日志是否会有帮助。

    # 可达对象
    git rev-list --disk-usage --objects --all
    # 加上 reflog
    git rev-list --disk-usage --objects --all --reflog
    # 所有占用的磁盘空间
    du -c .git/objects/pack/*.pack .git/objects/??/*
    # 切换到 du: 将 "size" 和 "size-pack" 字段合计
    git count-objects -v
  • 报告每个分支的磁盘大小,不包括当前分支使用的对象。这样就能发现导致仓库大小臃肿的异常值(例如,因为有人不小心提交了大容量的构建工件)。

    git for-each-ref --format='%(引用名)' |
    while read branch
    do
    	size=$(git rev-list --disk-usage --objects HEAD..$branch)
    	echo "$size $branch"
    done |
    sort -n
  • 比较一组分支的磁盘大小,排除另一组分支。如果在单个版本库中共同混合了来自多个远程的对象,这可以显示哪些远程对仓库的大小有影响(以 origin 的大小为基准)。

    git rev-list --disk-usage --objects --remotes=$suspect --not --remotes=origin

GIT

属于 git[1] 文档

scroll-to-top