mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-08 23:14:06 +08:00
29 lines
124 KiB
HTML
29 lines
124 KiB
HTML
<div class="c-markdown doc-markdown"><div class="doc-postil"><div class="c-markdown"><h2>名称</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>git-log - 显示提交日志</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>概要</h2></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash">git log [<options>] [<revision range>] [[\--] <path>…]</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><h2>描述</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>显示提交日志。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>该命令将采用适用于该<code>git rev-list</code>命令的选项来控制显示的内容和方式,以及适用于这些<code>git diff-*</code>命令的选项以控制每个提交所引发的更改的方式。</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>选项</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>--follow</p></div></div><div class="doc-postil"><div class="c-markdown"><p>继续列出除重命名之外的文件历史记录(仅适用于单个文件)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-decorate --decorate=short|full|auto|no</p></div></div><div class="doc-postil"><div class="c-markdown"><p>打印出任何提交的 ref 名称。如果<code>short</code>被指定,ref 名称前缀<code>refs/heads/</code>,<code>refs/tags/</code>并且<code>refs/remotes/</code>将不被打印。如果<code>full</code>指定,将打印完整的参考名称(包括前缀)。如果<code>auto</code>被指定,那么如果输出到达终端,则 ref 名称显示为如果<code>short</code>给定,否则不显示 ref 名称。默认选项是<code>short</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--source</p></div></div><div class="doc-postil"><div class="c-markdown"><p>打印出每个提交到达的命令行给定的 ref 名称。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--use-mailmap</p></div></div><div class="doc-postil"><div class="c-markdown"><p>使用邮件地图文件将作者和提交者姓名和电子邮件地址映射到规范的实名和电子邮件地址。参见 git-shortlog [1]。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--full-diff</p></div></div><div class="doc-postil"><div class="c-markdown"><p>没有此标志,<code>git log -p <path>...</code>显示提交触摸指定的路径,并且差异关于相同的指定的路径。通过这个,完整的差异显示为触及指定路径的提交; 这意味着“<path> ...”限制仅提交,并且不会限制这些提交的差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>请注意,这会影响所有基于差异的输出类型,例如由其生成的输出类型<code>--stat</code>等。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--log-size</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在每个提交的输出中包含一行“log size <number>”,其中<number>是该提交消息的长度(以字节为单位)。旨在<code>git log</code>通过提前分配空间来加速从输出中读取日志消息的工具。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-L <start>,<end>:<file> -L :<funcname>:<file></p></div></div><div class="doc-postil"><div class="c-markdown"><p>跟踪<file>中由“<start>,<end>”(或函数名称 regex <funcname>)给出的行范围的演变。您不可以提供任何路径限制器。这目前仅限于从单一修订开始,也就是说,您可能只给出零个或一个正面修订参数。您可以多次指定此选项。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><开始>和<结束>可以采取以下形式之一:</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p>数字如果<开始>或<结束>是一个数字,它将指定一个绝对行号(行数从1开始)。</p></li><li><p>/ regex /此表单将使用与给定的POSIX正则表达式匹配的第一行。如果<start>是一个正则表达式,它将从前一个<code>-L</code>范围的末尾(如果有的话)开始搜索,否则从文件起始处开始搜索。如果<start>是“^ / regex /”,它将从文件开头搜索。如果<end>是一个正则表达式,它将从<start>给出的行开始搜索。</p></li><li><p>+ offset或-offset这仅对<end>有效,并将在<start>给出的行之前或之后指定行数。</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>如果给出“:<funcname>”来代替<start>和<end>,它是一个正则表达式,表示从匹配<funcname>的第一个funcname行到下一个funcname行的范围。“:<funcname>”从上一个<code>-L</code>范围的末尾(如果有)搜索,否则从文件开头搜索。“^:<funcname>”从文件开头搜索。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><revision range></p></div></div><div class="doc-postil"><div class="c-markdown"><p>仅显示指定修订范围内的提交。当没有指定<revision range>时,它默认为<code>HEAD</code>(即导致当前提交的整个历史记录)。<code>origin..HEAD</code>指定从当前提交(ie <code>HEAD</code>)可访问的所有提交,但不从<code>origin</code>。有关拼写<修订范围>的完整列表,请参阅gitrevisions [7]<code>Specifying Ranges</code>部分。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-- <path>…</p></div></div><div class="doc-postil"><div class="c-markdown"><p>仅显示足以解释如何匹配指定路径的文件的提交。有关<code>History Simplification</code>详细信息和其他简化模式,请参阅下文。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>出现混淆时,路径可能需要加前缀“ - ”,以将它们与选项或修订范围分开。</p></div></div><div class="doc-postil"><div class="c-markdown"><h3>提交限制</h3></div></div><div class="doc-postil"><div class="c-markdown"><p>除了指定应使用描述中解释的特殊符号列出的提交范围之外,还可以应用其他提交限制。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>除非另有说明,否则使用更多选项通常会进一步限制输出(例如<code>--since=<date1></code>限制为提交更新<code><date1></code>,并将其与<code>--grep=<pattern></code>对其日志消息具有匹配的提交的进一步限制进行使用<code><pattern></code>)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>请注意,在提交排序和格式化选项之前应用这些选项,例如<code>--reverse</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-<number> -n <number> --max-count=<number></p></div></div><div class="doc-postil"><div class="c-markdown"><p>限制提交输出的数量。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--skip=<number></p></div></div><div class="doc-postil"><div class="c-markdown"><p>在开始显示提交输出之前跳过提交<code>number</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--since=<date> --after=<date></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示比特定日期更近的提交。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--until=<date> --before=<date></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示比特定日期更早的提交。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--author=<pattern> --committer=<pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>将提交输出限制为与指定模式(正则表达式)匹配的作者/提交者标题行。使用多于一个<code>--author=<pattern></code>,选择作者匹配任何给定模式的提交(类似地为多个<code>--committer=<pattern></code>)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--grep-reflog=<pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>将提交输出限制为具有与指定模式(正则表达式)匹配的 reflog 条目的提交输出。使用多于一个<code>--grep-reflog</code>,选择其 reflog 消息匹配任何给定模式的提交。除非<code>--walk-reflogs</code>正在使用,否则使用此选项是错误的。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--grep=<pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>将提交输出限制为符合指定模式(正则表达式)的日志消息。使用多于一个<code>--grep=<pattern></code>,提交的消息匹配任何给定模式的提交被选中(但请参阅<code>--all-match</code>)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>当<code>--show-notes</code>生效时,来自笔记的消息就好像它是日志消息的一部分一样。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--all-match</p></div></div><div class="doc-postil"><div class="c-markdown"><p>将提交输出限制为匹配所有给定的提交<code>--grep</code>,而不是至少匹配一个提交。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--invert-grep</p></div></div><div class="doc-postil"><div class="c-markdown"><p>将提交输出限制为与日志消息不匹配的模式<code>--grep=<pattern></code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-i --regexp-ignore-case</p></div></div><div class="doc-postil"><div class="c-markdown"><p>匹配正则表达式限制模式而不考虑字母大小写。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--basic-regexp</p></div></div><div class="doc-postil"><div class="c-markdown"><p>考虑限制模式是基本的正则表达式; 这是默认值。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-E --extended-regexp</p></div></div><div class="doc-postil"><div class="c-markdown"><p>考虑限制模式是扩展正则表达式而不是默认的基本正则表达式。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-F --fixed-strings</p></div></div><div class="doc-postil"><div class="c-markdown"><p>考虑限制模式为固定字符串(不要将模式解释为正则表达式)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-P --perl-regexp</p></div></div><div class="doc-postil"><div class="c-markdown"><p>考虑限制模式是与 Perl 兼容的正则表达式。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>对这些类型的正则表达式的支持是可选的编译时间依赖性。如果 Git 没有编译支持它们,提供这个选项会导致它死亡。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--remove-empty</p></div></div><div class="doc-postil"><div class="c-markdown"><p>当给定的路径从树上消失时停止。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--merges</p></div></div><div class="doc-postil"><div class="c-markdown"><p>仅打印合并提交。这与<code>--min-parents=2</code>完全一样。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-merges</p></div></div><div class="doc-postil"><div class="c-markdown"><p>不要打印与多个父代的提交。这与<code>--max-parents=1</code>完全一样。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--min-parents=<number> --max-parents=<number> --no-min-parents --no-max-parents</p></div></div><div class="doc-postil"><div class="c-markdown"><p>仅显示至少(或至多)多次父级提交的提交。特别<code>--max-parents=1</code>是一样的<code>--no-merges</code>,<code>--min-parents=2</code>是一样的<code>--merges</code>。<code>--max-parents=0</code>给出所有的根提交和<code>--min-parents=3</code>所有子分支合并。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>--no-min-parents</code>和<code>--no-max-parents</code>重新设置这些限制(无限制)。等价形式是<code>--min-parents=0</code>(任何承诺有0或更多父母)和<code>--max-parents=-1</code>(负数表示没有上限)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--first-parent</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在查看合并提交后,只跟踪第一个父提交。当查看特定主题分支的演变时,此选项可以提供更好的概述,因为合并到主题分支往往只是适应不断更新的上游时间,并且此选项允许您忽略单独提交到你的历史通过这样的合并。不能与--bisect结合使用。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--not</p></div></div><div class="doc-postil"><div class="c-markdown"><p>颠倒<code>^</code>所有后续修订说明符的前缀(或缺少)的含义,直到下一个<code>--not</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--all</p></div></div><div class="doc-postil"><div class="c-markdown"><p>假设所有的参考文件<code>refs/</code>,以及<code>HEAD</code>命令行都列为<code><commit></code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--branches=<pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>假设所有的参数<code>refs/heads</code>都在命令行中列为<code><commit></code>。如果<code><pattern></code>给出,则将分支限制为与给定shell glob 匹配的分支。如果模式没有<code>?</code>,<code>*</code>或者<code>[</code>,<code>/*</code>在结束时暗示。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--tags=<pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>假设所有的参数<code>refs/tags</code>都在命令行中列为<code><commit></code>。如果<code><pattern></code>给出,则将标签限制为与给定 shell glob 匹配的标签。如果模式没有<code>?</code>,<code>*</code>或者<code>[</code>,<code>/*</code>在结束时暗示。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--remotes=<pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>假设所有的参数<code>refs/remotes</code>都在命令行中列为<code><commit></code>。如果<code><pattern></code>给出,则将远程跟踪分支限制为与给定 shell glob 匹配的分支。如果模式没有<code>?</code>,<code>*</code>或者<code>[</code>,<code>/*</code>在结束时暗示。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--glob=<glob-pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>假设所有与 shell glob 匹配的 ref <code><glob-pattern></code>都在命令行中列出<code><commit></code>。领导<code>refs/</code>,如果失踪,会自动添加前缀。如果模式没有<code>?</code>,<code>*</code>或者<code>[</code>,<code>/*</code>在结束时暗示。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--exclude=<glob-pattern></p></div></div><div class="doc-postil"><div class="c-markdown"><p>不包括裁判匹配<code><glob-pattern></code>,未来<code>--all</code>,<code>--branches</code>,<code>--tags</code>,<code>--remotes</code>,或<code>--glob</code>原本考虑。这个选项排除累积模式到下一个的重复<code>--all</code>,<code>--branches</code>,<code>--tags</code>,<code>--remotes</code>,或<code>--glob</code>选择(其他选项或参数不清除积累的模式)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>给予不应该开始的模式<code>refs/heads</code>,<code>refs/tags</code>或<code>refs/remotes</code>当应用到<code>--branches</code>,<code>--tags</code>或<code>--remotes</code>分别,他们必须开始<code>refs/</code>在应用于<code>--glob</code>或<code>--all</code>。如果尾随<code>/*</code>是有意的,则必须明确给出。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--reflog</p></div></div><div class="doc-postil"><div class="c-markdown"><p>假设所有 reflog 提到的对象都在命令行中列为<code><commit></code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ignore-missing</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在输入中看到一个无效的对象名称时,假装没有给出错误的输入。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--bisect</p></div></div><div class="doc-postil"><div class="c-markdown"><p>假装好坏的二等分参考文献<code>refs/bisect/bad</code>被列出,并且仿佛它被跟随,<code>--not</code>并且良好的平分参考<code>refs/bisect/good-*</code>命令行。不能与--first-parent 结合使用。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--stdin</p></div></div><div class="doc-postil"><div class="c-markdown"><p>除了<code><commit></code>在命令行上列出之外,还要从标准输入中读取它们。如果<code>--</code>看到分隔符,请停止读取提交并开始读取路径以限制结果。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--cherry-mark</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Like <code>--cherry-pick</code> (see below) but mark equivalent commits with <code>=</code> rather than omitting them, and inequivalent ones with <code>+</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--cherry-pick</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Omit any commit that introduces the same change as another commit on the “other side” when the set of commits are limited with symmetric difference.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>For example, if you have two branches, <code>A</code> and <code>B</code>, a usual way to list all commits on only one side of them is with <code>--left-right</code> (see the example below in the description of the <code>--left-right</code> option). However, it shows the commits that were cherry-picked from the other branch (for example, “3rd on b” may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--left-only --right-only</p></div></div><div class="doc-postil"><div class="c-markdown"><p>List only commits on the respective side of a symmetric difference, i.e. only those which would be marked <code><</code> resp. <code>></code> by <code>--left-right</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>For example, <code>--cherry-pick --right-only A...B</code> omits those commits from <code>B</code> which are in <code>A</code> or are patch-equivalent to a commit in <code>A</code>. In other words, this lists the <code>+</code> commits from <code>git cherry A B</code>. More precisely, <code>--cherry-pick --right-only --no-merges</code> gives the exact list.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--cherry</p></div></div><div class="doc-postil"><div class="c-markdown"><p>A synonym for <code>--right-only --cherry-mark --no-merges</code>; useful to limit the output to the commits on our side and mark those that have been applied to the other side of a forked history with <code>git log --cherry upstream...mybranch</code>, similar to <code>git cherry upstream mybranch</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-g --walk-reflogs</p></div></div><div class="doc-postil"><div class="c-markdown"><p>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, <code>^commit</code>, <code>commit1..commit2</code>, and <code>commit1...commit2</code> notations cannot be used).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>With <code>--pretty</code> format other than <code>oneline</code> (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 <code>ref@{Nth}</code> (where <code>Nth</code> is the reverse-chronological index in the reflog) or as <code>ref@{timestamp}</code> (with the timestamp for that entry), depending on a few rules:</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>If the starting point is specified as <code>ref@{Nth}</code>, show the index format.</p></li><li><p>If the starting point was specified as <code>ref@{now}</code>, show the timestamp format.</p></li><li><p>If neither was used, but <code>--date</code> was given on the command line, show the timestamp in the format requested by <code>--date</code>.</p></li><li><p>Otherwise, show the index format.</p></li></ol><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p>Under <code>--pretty=oneline</code>, the commit message is prefixed with this information on the same line. This option cannot be combined with <code>--reverse</code>. See also git-reflog[1].</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>--merge</p></div></div><div class="doc-postil"><div class="c-markdown"><p>After a failed merge, show refs that touch files having a conflict and don’t exist on all heads to merge.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--boundary</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Output excluded boundary commits. Boundary commits are prefixed with <code>-</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><h3>History Simplification</h3></div></div><div class="doc-postil"><div class="c-markdown"><p>Sometimes you are only interested in parts of the history, for example the commits modifying a particular <path>. But there are two parts of <code>History Simplification</code>, one part is selecting the commits and the other is how to do it, as there are various strategies to simplify the history.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>The following options select the commits to be shown:</p></div></div><div class="doc-postil"><div class="c-markdown"><p><paths></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Commits modifying the given <paths> are selected.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--simplify-by-decoration</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Commits that are referred by some branch or tag are selected.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Note that extra commits can be shown to give a meaningful history.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>The following options affect the way the simplification is performed:</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Default mode</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Simplifies the history to the simplest history explaining the final state of the tree. Simplest because it prunes some side branches if the end result is the same (i.e. merging branches with the same content)</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--full-history</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Same as the default mode, but does not prune some history.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--dense</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Only the selected commits are shown, plus some to have a meaningful history.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--sparse</p></div></div><div class="doc-postil"><div class="c-markdown"><p>All commits in the simplified history are shown.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--simplify-merges</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Additional option to <code>--full-history</code> to remove some needless merges from the resulting history, as there are no selected commits contributing to this merge.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ancestry-path</p></div></div><div class="doc-postil"><div class="c-markdown"><p>When given a range of commits to display (e.g. <code>commit1..commit2</code> or <code>commit2 ^commit1</code>), only display commits that exist directly on the ancestry chain between the <code>commit1</code> and <code>commit2</code>, i.e. commits that are both descendants of <code>commit1</code>, and ancestors of <code>commit2</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>A more detailed explanation follows.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Suppose you specified <code>foo</code> as the <paths>. We shall call commits that modify <code>foo</code> !TREESAME, and the rest TREESAME. (In a diff filtered for <code>foo</code>, they look different and equal, respectively.)</p></div></div><div class="doc-postil"><div class="c-markdown"><p>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 <code>foo</code> in this commit graph:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> .-A---M---N---O---P---Q / / / / / /
|
||
|
||
I B C D E Y
|
||
|
||
\ / / / / /
|
||
|
||
`-------------' X</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>The horizontal line of history A---Q is taken to be the first parent of each merge. The commits are:</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>I</code> is the initial commit, in which <code>foo</code> exists with contents “asdf”, and a file <code>quux</code> exists with contents “quux”. Initial commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p></li><li><p>In <code>A</code>, <code>foo</code> contains just “foo”.</p></li><li><p><code>B</code> contains the same change as <code>A</code>. Its merge <code>M</code> is trivial and hence TREESAME to all parents.</p></li><li><p><code>C</code> does not change <code>foo</code>, but its merge <code>N</code> changes it to “foobar”, so it is not TREESAME to any parent.</p></li><li><p><code>D</code> sets <code>foo</code> to “baz”. Its merge <code>O</code> combines the strings from <code>N</code> and <code>D</code> to “foobarbaz”; i.e., it is not TREESAME to any parent.</p></li><li><p><code>E</code> changes <code>quux</code> to “xyzzy”, and its merge <code>P</code> combines the strings to “quux xyzzy”. <code>P</code> is TREESAME to <code>O</code>, but not to <code>E</code>.</p></li><li><p><code>X</code> is an independent root commit that added a new file <code>side</code>, and <code>Y</code> modified it. <code>Y</code> is TREESAME to <code>X</code>. Its merge <code>Q</code> added <code>side</code> to <code>P</code>, and <code>Q</code> is TREESAME to <code>P</code>, but not to <code>Y</code>.</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p><code>rev-list</code> walks backwards through history, including or excluding commits based on whether <code>--full-history</code> and/or parent rewriting (via <code>--parents</code> or <code>--children</code>) are used. The following settings are available.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Default mode</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Commits are included if they are not TREESAME to any parent (though this can be changed, see <code>--sparse</code> 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.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>This results in:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> .-A---N---O / / /
|
||
|
||
I---------D</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>Note how the rule to only follow the TREESAME parent, if one is available, removed <code>B</code> from consideration entirely. <code>C</code> was considered via <code>N</code>, but is TREESAME. Root commits are compared to an empty tree, so <code>I</code> is !TREESAME.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Parent/child relations are only visible with <code>--parents</code>, but that does not affect the commits selected in default mode, so we have shown the parent lines.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--full-history without parent rewriting</p></div></div><div class="doc-postil"><div class="c-markdown"><p>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</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> I A B N D O P Q</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p><code>M</code> was excluded because it is TREESAME to both parents. <code>E</code>, <code>C</code> and <code>B</code> were all walked, but only <code>B</code> was !TREESAME, so the others do not appear.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Note that without parent rewriting, it is not really possible to talk about the parent/child relationships between the commits, so we show them disconnected.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--full-history with parent rewriting</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Ordinary commits are only included if they are !TREESAME (though this can be changed, see <code>--sparse</code> below).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Merges are always included. However, their parent list is rewritten: Along each parent, prune away commits that are not included themselves. This results in</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> .-A---M---N---O---P---Q / / / / /
|
||
|
||
I B / D /
|
||
|
||
\ / / / /
|
||
|
||
`-------------'</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>Compare to <code>--full-history</code> without rewriting above. Note that <code>E</code> was pruned away because it is TREESAME, but the parent list of P was rewritten to contain <code>E</code>'s parent <code>I</code>. The same happened for <code>C</code> and <code>N</code>, and <code>X</code>, <code>Y</code> and <code>Q</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>In addition to the above settings, you can change whether TREESAME affects inclusion:</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--dense</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Commits that are walked are included if they are not TREESAME to any parent.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--sparse</p></div></div><div class="doc-postil"><div class="c-markdown"><p>All commits that are walked are included.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Note that without <code>--full-history</code>, this still simplifies merges: if one of the parents is TREESAME, we follow only that one, so the other sides of the merge are never walked.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--simplify-merges</p></div></div><div class="doc-postil"><div class="c-markdown"><p>First, build a history graph in the same way that <code>--full-history</code> with parent rewriting does (see above).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Then simplify each commit <code>C</code> to its replacement <code>C'</code> in the final history according to the following rules:</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p>Set <code>C'</code> to <code>C</code>.</p></li><li><p>Replace each parent <code>P</code> of <code>C'</code> with its simplification <code>P'</code>. 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.</p></li><li><p>If after this parent rewriting, <code>C'</code> 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.</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>The effect of this is best shown by way of comparing to <code>--full-history</code> with parent rewriting. The example turns into:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> .-A---M---N---O / / /
|
||
|
||
I B D
|
||
|
||
\ / /
|
||
|
||
`---------'</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>Note the major differences in <code>N</code>, <code>P</code>, and <code>Q</code> over <code>--full-history</code>:</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>N</code>'s parent list had <code>I</code> removed, because it is an ancestor of the other parent <code>M</code>. Still, <code>N</code> remained because it is !TREESAME.</p></li><li><p><code>P</code>'s parent list similarly had <code>I</code> removed. <code>P</code> was then removed completely, because it had one parent and is TREESAME.</p></li><li><p><code>Q</code>'s parent list had <code>Y</code> simplified to <code>X</code>. <code>X</code> was then removed, because it was a TREESAME root. <code>Q</code> was then removed completely, because it had one parent and is TREESAME.</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>Finally, there is a fifth simplification mode available:</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ancestry-path</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Limit the displayed commits to those directly on the ancestry chain between the “from” and “to” commits in the given commit range. I.e. only display commits that are ancestor of the “to” commit and descendants of the “from” commit.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>As an example use case, consider the following commit history:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> D---E-------F / \ \
|
||
|
||
B---C---G---H---I---J / \
|
||
|
||
A-------K---------------L--M</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>A regular <code>D..M</code> computes the set of commits that are ancestors of <code>M</code>, but excludes the ones that are ancestors of <code>D</code>. This is useful to see what happened to the history leading to <code>M</code> since <code>D</code>, in the sense that “what does <code>M</code> have that did not exist in <code>D</code>”. The result in this example would be all the commits, except <code>A</code> and <code>B</code> (and <code>D</code> itself, of course).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>When we want to find out what commits in <code>M</code> are contaminated with the bug introduced by <code>D</code> and need fixing, however, we might want to view only the subset of <code>D..M</code> that are actually descendants of <code>D</code>, i.e. excluding <code>C</code> and <code>K</code>. This is exactly what the <code>--ancestry-path</code> option does. Applied to the <code>D..M</code> range, it results in:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> E-------F
|
||
|
||
\ \
|
||
|
||
G---H---I---J
|
||
|
||
\
|
||
|
||
L--M</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>The <code>--simplify-by-decoration</code> 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).</p></div></div><div class="doc-postil"><div class="c-markdown"><h3>Commit Ordering</h3></div></div><div class="doc-postil"><div class="c-markdown"><p>By default, the commits are shown in reverse chronological order.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--date-order</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--author-date-order</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Show no parents before all of its children are shown, but otherwise show commits in the author timestamp order.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--topo-order</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Show no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>For example, in a commit history like this:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> ---1----2----4----7
|
||
|
||
\ \ 3----5----6----8---</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>where the numbers denote the order of commit timestamps, <code>git rev-list</code> and friends with <code>--date-order</code> show the commits in the timestamp order: 8 7 6 5 4 3 2 1.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>With <code>--topo-order</code>, they would show 8 6 5 3 7 4 2 1 (or 8 7 4 2 6 5 3 1); some older commits are shown before newer ones in order to avoid showing the commits from two parallel development track mixed together.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--reverse</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Output the commits chosen to be shown (see Commit Limiting section above) in reverse order. Cannot be combined with <code>--walk-reflogs</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><h3>Object Traversal</h3></div></div><div class="doc-postil"><div class="c-markdown"><p>These options are mostly targeted for packing of Git repositories.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-walk=(sorted|unsorted)</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Only show the given commits, but do not traverse their ancestors. This has no effect if a range is specified. If the argument <code>unsorted</code> is given, the commits are shown in the order they were given on the command line. Otherwise (if <code>sorted</code> or no argument was given), the commits are shown in reverse chronological order by commit time. Cannot be combined with <code>--graph</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--do-walk</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Overrides a previous <code>--no-walk</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><h3>Commit Formatting</h3></div></div><div class="doc-postil"><div class="c-markdown"><p>--pretty=<format> --format=<format></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Pretty-print the contents of the commit logs in a given format, where <code><format></code> can be one of <code>oneline</code>, <code>short</code>, <code>medium</code>, <code>full</code>, <code>fuller</code>, <code>email</code>, <code>raw</code>, <code>format:<string></code> and <code>tformat:<string></code>. When <code><format></code> is none of the above, and has <code>%placeholder</code> in it, it acts as if <code>--pretty=tformat:<format></code> were given.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>See the "PRETTY FORMATS" section for some additional details for each format. When <code>=<format></code> part is omitted, it defaults to <code>medium</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Note: you can specify the default pretty format in the repository configuration (see git-config[1]).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--abbrev-commit</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix. Non default number of digits can be specified with "--abbrev=<n>" (which also modifies diff output, if it is displayed).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>This should make "--pretty=oneline" a whole lot more readable for people using 80-column terminals.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-abbrev-commit</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Show the full 40-byte hexadecimal commit object name. This negates <code>--abbrev-commit</code> and those options which imply it such as "--oneline". It also overrides the <code>log.abbrevCommit</code> variable.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--oneline</p></div></div><div class="doc-postil"><div class="c-markdown"><p>This is a shorthand for "--pretty=oneline --abbrev-commit" used together.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--encoding=<encoding></p></div></div><div class="doc-postil"><div class="c-markdown"><p>The commit objects record the encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. Note that if an object claims to be encoded in <code>X</code> and we are outputting in <code>X</code>, we will output the object verbatim; this means that invalid sequences in the original commit may be copied to the output.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--expand-tabs=<n> --expand-tabs --no-expand-tabs</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Perform a tab expansion (replace each tab with enough spaces to fill to the next display column that is multiple of <code><n></code>) in the log message before showing it in the output. <code>--expand-tabs</code> is a short-hand for <code>--expand-tabs=8</code>, and <code>--no-expand-tabs</code> is a short-hand for <code>--expand-tabs=0</code>, which disables tab expansion.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>By default, tabs are expanded in pretty formats that indent the log message by 4 spaces (i.e. <code>medium</code>, which is the default, <code>full</code>, and <code>fuller</code>).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--notes=<treeish></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Show the notes (see git-notes[1]) that annotate the commit, when showing the commit log message. This is the default for <code>git log</code>, <code>git show</code> and <code>git whatchanged</code> commands when there is no <code>--pretty</code>, <code>--format</code>, or <code>--oneline</code> option given on the command line.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>By default, the notes shown are from the notes refs listed in the <code>core.notesRef</code> and <code>notes.displayRef</code> variables (or corresponding environment overrides). See git-config[1] for more details.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>With an optional <code><treeish></code> argument, use the treeish to find the notes to display. The treeish can specify the full refname when it begins with <code>refs/notes/</code>; when it begins with <code>notes/</code>, <code>refs/</code> and otherwise <code>refs/notes/</code> is prefixed to form a full name of the ref.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Multiple --notes options can be combined to control which notes are being displayed. Examples: "--notes=foo" will show only notes from "refs/notes/foo"; "--notes=foo --notes" will show both notes from "refs/notes/foo" and from the default notes ref(s).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-notes</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Do not show notes. This negates the above <code>--notes</code> option, by resetting the list of notes refs from which notes are shown. Options are parsed in the order given on the command line, so e.g. "--notes --notes=foo --no-notes --notes=bar" will only show notes from "refs/notes/bar".</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--show-notes=<treeish> --no-standard-notes</p></div></div><div class="doc-postil"><div class="c-markdown"><p>These options are deprecated. Use the above --notes/--no-notes options instead.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--show-signature</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Check the validity of a signed commit object by passing the signature to <code>gpg --verify</code> and show the output.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--relative-date</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Synonym for <code>--date=relative</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--date=<format></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Only takes effect for dates shown in human-readable format, such as when using <code>--pretty</code>. <code>log.date</code> config variable sets a default value for the log command’s <code>--date</code> option. By default, dates are shown in the original time zone (either committer’s or author’s). If <code>-local</code> is appended to the format (e.g., <code>iso-local</code>), the user’s local time zone is used instead.</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>--date=relative</code> shows dates relative to the current time, e.g. “2 hours ago”. The <code>-local</code> option has no effect for <code>--date=relative</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>--date=local</code> is an alias for <code>--date=default-local</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>--date=iso</code> (or <code>--date=iso8601</code>) shows timestamps in a ISO 8601-like format. The differences to the strict ISO 8601 format are:</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p>a space instead of the <code>T</code> date/time delimiter</p></li><li><p>a space between time and time zone</p></li><li><p>no colon between hours and minutes of the time zone</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p><code>--date=iso-strict</code> (or <code>--date=iso8601-strict</code>) shows timestamps in strict ISO 8601 format.</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>--date=rfc</code> (or <code>--date=rfc2822</code>) shows timestamps in RFC 2822 format, often found in email messages.</p></li><li><p><code>--date=short</code> shows only the date, but not the time, in <code>YYYY-MM-DD</code> format.</p></li><li><p><code>--date=raw</code> 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 <code>+</code> or <code>-</code> with four digits; the first two are hours, and the second two are minutes). I.e., as if the timestamp were formatted with <code>strftime("%s %z")</code>). Note that the <code>-local</code> option does not affect the seconds-since-epoch value (which is always measured in UTC), but does switch the accompanying timezone value.</p></li><li><p><code>--date=unix</code> shows the date as a Unix epoch timestamp (seconds since 1970). As with <code>--raw</code>, this is always in UTC and therefore <code>-local</code> has no effect.</p></li><li><p><code>--date=format:...</code> feeds the format <code>...</code> to your system <code>strftime</code>, except for %z and %Z, which are handled internally. Use <code>--date=format:%c</code> to show the date in your system locale’s preferred format. See the <code>strftime</code> manual for a complete list of format placeholders. When using <code>-local</code>, the correct syntax is <code>--date=format-local:...</code>.</p></li><li><p><code>--date=default</code> is the default format, and is similar to <code>--date=rfc2822</code>, with a few exceptions:</p></li><li><p>there is no comma after the day-of-week</p></li><li><p>the time zone is omitted when the local time zone is used</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>--parents</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Print also the parents of the commit (in the form "commit parent…"). Also enables parent rewriting, see <code>History Simplification</code> below.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--children</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Print also the children of the commit (in the form "commit child…"). Also enables parent rewriting, see <code>History Simplification</code> below.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--left-right</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Mark which side of a symmetric difference a commit is reachable from. Commits from the left side are prefixed with <code><</code> and those from the right with <code>></code>. If combined with <code>--boundary</code>, those commits are prefixed with <code>-</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>For example, if you have this topology:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> y---b---b branch B / \ / / . / / \
|
||
|
||
o---x---a---a branch A</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>you would get an output like this:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash"> $ 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</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>--graph</p></div></div><div class="doc-postil"><div class="c-markdown"><p>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 <code>--no-walk</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>This enables parent rewriting, see <code>History Simplification</code> below.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>This implies the <code>--topo-order</code> option by default, but the <code>--date-order</code> option may also be specified.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--show-linear-break=<barrier></p></div></div><div class="doc-postil"><div class="c-markdown"><p>When --graph is not used, all history branches are flattened which can make it hard to see that the two consecutive commits do not belong to a linear branch. This option puts a barrier in between them in that case. If <code><barrier></code> is specified, it is the string that will be shown instead of the default one.</p></div></div><div class="doc-postil"><div class="c-markdown"><h3>Diff Formatting</h3></div></div><div class="doc-postil"><div class="c-markdown"><p>Listed below are options that control the formatting of diff output. Some of them are specific to git-rev-list[1], however other diff options may be given. See git-diff-files[1] for more options.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-c</p></div></div><div class="doc-postil"><div class="c-markdown"><p>With this option, diff output for a merge commit shows the differences from each of the parents to the merge result simultaneously instead of showing pairwise diff between a parent and the result one at a time. Furthermore, it lists only files which were modified from all parents.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--cc</p></div></div><div class="doc-postil"><div class="c-markdown"><p>This flag implies the <code>-c</code> option and further compresses the patch output by omitting uninteresting hunks whose contents in the parents have only two variants and the merge result picks one of them without modification.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-m</p></div></div><div class="doc-postil"><div class="c-markdown"><p>This flag makes the merge commits show the full diff like regular commits; for each merge parent, a separate log entry and diff is generated. An exception is that only diff against the first parent is shown when <code>--first-parent</code> option is given; in that case, the output represents the changes the merge brought <code>into</code> the then-current branch.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-r</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Show recursive diffs.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-t</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Show the tree objects in the diff output. This implies <code>-r</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>Pretty formats</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>If the commit is a merge, and if the pretty-format is not <code>oneline</code>, <code>email</code> or <code>raw</code>, an additional line is inserted before the <code>Author:</code> line. This line begins with "Merge: " and the sha1s of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the <strong>direct</strong> 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.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>There are several built-in formats, and you can define additional formats by setting a pretty.<name> config option to either another format name, or a <code>format:</code> string, as described below (see git-config[1]). Here are the details of the built-in formats:</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>oneline</code><sha1> <title line></p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>This is designed to be as compact as possible.</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>short</code>commit <sha1> Author: <author></p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p><title line></p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>medium</code>commit <sha1> Author: <author> Date: <author date></p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p><title line></p></div></div><div class="doc-postil"><div class="c-markdown"><p><full commit message></p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>full</code>commit <sha1> Author: <author> Commit: <committer></p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p><title line></p></div></div><div class="doc-postil"><div class="c-markdown"><p><full commit message></p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>fuller</code>commit <sha1> Author: <author> AuthorDate: <author date> Commit: <committer> CommitDate: <committer date></p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p><title line></p></div></div><div class="doc-postil"><div class="c-markdown"><p><full commit message></p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>email</code>From <sha1> <date> From: <author> Date: <author date> Subject: PATCH <title line></p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p><full commit message></p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>raw</code>The <code>raw</code> format shows the entire commit exactly as stored in the commit object. Notably, the SHA-1s are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and <code>parents</code> 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 <code>git log --raw</code>. To get full object names in a raw diff format, use <code>--no-abbrev</code>.</p></li><li><p><code>format:<string></code>The <code>format:<string></code> format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with <code>%n</code> instead of <code>\n</code>.
|
||
|
||
E.g, <code>format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"</code> would show something like this:
|
||
|
||
The author of fe6e0ee was Junio C Hamano, 23 hours ago The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>The placeholders are:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%H`: commit hash</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%h`: abbreviated commit hash</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%T`: tree hash</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%t`: abbreviated tree hash</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%P`: parent hashes</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%p`: abbreviated parent hashes</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%an`: author name</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%aN`: author name (respecting .mailmap, see [git-shortlog[1]](git-shortlog) or [git-blame[1]](git-blame))</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ae`: author email</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%aE`: author email (respecting .mailmap, see [git-shortlog[1]](git-shortlog) or [git-blame[1]](git-blame))</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ad`: author date (format respects --date= option)</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%aD`: author date, RFC2822 style</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ar`: author date, relative</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%at`: author date, UNIX timestamp</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ai`: author date, ISO 8601-like format</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%aI`: author date, strict ISO 8601 format</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%cn`: committer name</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%cN`: committer name (respecting .mailmap, see [git-shortlog[1]](git-shortlog) or [git-blame[1]](git-blame))</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ce`: committer email</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%cE`: committer email (respecting .mailmap, see [git-shortlog[1]](git-shortlog) or [git-blame[1]](git-blame))</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%cd`: committer date (format respects --date= option)</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%cD`: committer date, RFC2822 style</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%cr`: committer date, relative</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ct`: committer date, UNIX timestamp</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ci`: committer date, ISO 8601-like format</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%cI`: committer date, strict ISO 8601 format</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%d`: ref names, like the --decorate option of [git-log[1]](git-log)</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%D`: ref names without the " (", ")" wrapping.</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%e`: encoding</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%s`: subject</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%f`: sanitized subject line, suitable for a filename</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%b`: body</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%B`: raw body (unwrapped subject and body)</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%N`: commit notes</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%GG`: raw verification message from GPG for a signed commit</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%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</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%GS`: show the name of the signer for a signed commit</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%GK`: show the key used to sign a signed commit</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%gD`: reflog selector, e.g., `refs/stash@{1}` or `refs/stash@{2 minutes ago`}; the format follows the rules described for the `-g` option. The portion before the `@` is the refname as given on the command line (so `git log -g refs/heads/master` would yield `refs/heads/master@{0}`).</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%gd`: shortened reflog selector; same as `%gD`, but the refname portion is shortened for human readability (so `refs/heads/master` becomes just `master`).</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%gn`: reflog identity name</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%gN`: reflog identity name (respecting .mailmap, see [git-shortlog[1]](git-shortlog) or [git-blame[1]](git-blame))</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%ge`: reflog identity email</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%gE`: reflog identity email (respecting .mailmap, see [git-shortlog[1]](git-shortlog) or [git-blame[1]](git-blame))</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%gs`: reflog subject</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%Cred`: switch color to red</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%Cgreen`: switch color to green</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%Cblue`: switch color to blue</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%Creset`: reset color</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%C(…)`: color specification, as described under Values in the "CONFIGURATION FILE" section of [git-config[1]](git-config). 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 &grave;--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.</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%m`: left (`<`), right (`>`) or boundary (`-`) mark</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%n`: newline</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%%`: a raw `%`</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%x00`: print a byte from a hex code</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%w([<w>[,<i1>[,<i2>]]])`: switch line wrapping, like the -w option of [git-shortlog[1]](git-shortlog).</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%<(<N>[,trunc|ltrunc|mtrunc])`: make the next placeholder take at least N columns, padding spaces on the right if necessary. Optionally truncate at the beginning (ltrunc), the middle (mtrunc) or the end (trunc) if the output is longer than N columns. Note that truncating only works correctly with N >= 2.</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%<|(<N>)`: make the next placeholder take at least until Nth columns, padding spaces on the right if necessary</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%>(<N>)`, `%>|(<N>)`: similar to `%<(<N>)`, `%<|(<N>)` respectively, but padding spaces on the left</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%>>(<N>)`, `%>>|(<N>)`: similar to `%>(<N>)`, `%>|(<N>)` respectively, except that if the next placeholder takes more spaces than given and there are spaces on its left, use those spaces</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- `%><(<N>)`, `%><|(<N>)`: similar to `% <(<N>)`, `%<|(<N>)` respectively, but padding both sides (i.e. the text is centered)</pre></div></div><div class="doc-postil"><div class="c-markdown"><pre class="prism-token token language-js">- %(trailers): display the trailers of the body as interpreted by [git-interpret-trailers[1]](git-interpret-trailers)</pre></div></div><div class="doc-postil"><div class="c-markdown"><div class="table-wrapper"><table><thead><tr class="firstRow"><th style="text-align: left;"><div class="table-header"><p>Note</p></div></th><th style="text-align: left;"><div class="table-header"><p>Some placeholders may depend on other options given to the revision traversal engine. For example, the %g* reflog options will insert an empty string unless we are traversing reflog entries (e.g., by git log -g). The %d and %D placeholders will use the "short" decoration format if --decorate was not already provided on the command line.</p></div></th></tr></thead><tbody></tbody></table></div></div></div><div class="doc-postil"><div class="c-markdown"><p>If you add a <code>+</code> (plus sign) after <code>%</code> of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>If you add a <code>-</code> (minus sign) after <code>%</code> of a placeholder, all consecutive line-feeds immediately preceding the expansion are deleted if and only if the placeholder expands to an empty string.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>If you add a (space) after <code>%</code> of a placeholder, a space is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p><code>tformat:</code>The <code>tformat:</code> format works exactly like <code>format:</code>, 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</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>In addition, any unrecognized string that has a <code>%</code> in it is interpreted as if it has <code>tformat:</code> in front of it. For example, these two are equivalent:</p></div></div><div class="doc-postil"><div class="c-markdown"><p>$ git log -2 --pretty=tformat:%h 4da45bef $ git log -2 --pretty=%h 4da45bef</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>Common diff options</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>-p -u --patch</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Generate patch (see section on generating patches).</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-s --no-patch</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Suppress diff output. Useful for commands like <code>git show</code> that show the patch by default, or to cancel the effect of <code>--patch</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-U<n> --unified=<n></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Generate diffs with <n> lines of context instead of the usual three. Implies <code>-p</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--raw</p></div></div><div class="doc-postil"><div class="c-markdown"><p>For each commit, show a summary of changes using the raw diff format. See the "RAW OUTPUT FORMAT" section of git-diff[1]. This is different from showing the log itself in raw format, which you can achieve with <code>--format=raw</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--patch-with-raw</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Synonym for <code>-p --raw</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--indent-heuristic --no-indent-heuristic</p></div></div><div class="doc-postil"><div class="c-markdown"><p>These are to help debugging and tuning experimental heuristics (which are off by default) that shift diff hunk boundaries to make patches easier to read.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--minimal</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Spend extra time to make sure the smallest possible diff is produced.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--patience</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Generate a diff using the "patience diff" algorithm.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--histogram</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Generate a diff using the "histogram diff" algorithm.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--diff-algorithm={patience|minimal|histogram|myers}</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Choose a diff algorithm. The variants are as follows:</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>default</code>, <code>myers</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>The basic greedy diff algorithm. Currently, this is the default.</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>minimal</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Spend extra time to make sure the smallest possible diff is produced.</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>patience</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Use "patience diff" algorithm when generating patches.</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>histogram</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>This algorithm extends the patience algorithm to "support low-occurrence common elements".</p></div></div><div class="doc-postil"><div class="c-markdown"><p>For instance, if you configured diff.algorithm variable to a non-default value and want to use the default one, then you have to use <code>--diff-algorithm=default</code> option.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--stat[=<width>[,<name-width>,<count>]]</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <code><width></code>. The width of the filename part can be limited by giving another width <code><name-width></code> after a comma. The width of the graph part can be limited by using <code>--stat-graph-width=<width></code> (affects all commands generating a stat graph) or by setting <code>diff.statGraphWidth=<width></code> (does not affect <code>git format-patch</code>). By giving a third parameter <code><count></code>, you can limit the output to the first <code><count></code> lines, followed by <code>...</code> if there are more.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>These parameters can also be set individually with <code>--stat-width=<width></code>, <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--numstat</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Similar to <code>--stat</code>, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make it more machine friendly. For binary files, outputs two <code>-</code> instead of saying <code>0 0</code>.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--shortstat</p></div></div><div class="doc-postil"><div class="c-markdown"><p>Output only the last line of the <code>--stat</code> format containing total number of modified files, as well as number of added and deleted lines.</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--dirstat=<param1,param2,…></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Output the distribution of relative amount of changes for each sub-directory. The behavior of <code>--dirstat</code> can be customized by passing it a comma separated list of parameters. The defaults are controlled by the <code>diff.dirstat</code> configuration variable (see git-config[1]). The following parameters are available:</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>changes</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>Compute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. This ignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as much as other changes. This is the default behavior when no parameter is given.</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>lines</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>通过执行常规基于行的差异分析来计算 dirstat 数字,并且将移除/添加的行数相加。(对于二进制文件,取而代之的是计算64字节的块,因为二进制文件没有自然的行概念)。这是一种<code>--dirstat</code>比<code>changes</code>行为更为昂贵的行为,但它可以像其他更改一样对文件中的重新排列的行进行计数。结果输出与您从其他<code>--*stat</code>选项中获得的结果一致。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>files</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>通过计算更改的文件数量来计算 dirstat 数字。dirstat 分析中每个更改的文件都相同。这是计算上最便宜的<code>--dirstat</code>行为,因为它根本不需要查看文件内容。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>cumulative</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>计数父目录的子目录中的更改。请注意,使用时<code>cumulative</code>,报告的百分比总和可能超过100%。默认(非累积)行为可以用<code>noncumulative</code>参数指定。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><limit></p></div></div><div class="doc-postil"><div class="c-markdown"><p>整数参数指定截断百分比(默认为3%)。输出中不显示贡献小于此百分比的目录。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>示例:以下内容将计数已更改的文件,同时忽略占已更改文件总数少于10%的目录,并累积父目录中的子目录计数:<code>--dirstat=files,10,cumulative</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--summary</p></div></div><div class="doc-postil"><div class="c-markdown"><p>输出扩展头信息的精简摘要,如创建,重命名和模式更改。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--patch-with-stat</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>-p --stat</code>的同义词。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-z</p></div></div><div class="doc-postil"><div class="c-markdown"><p>用多个 NUL 分开提交,而不用新的换行符。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>此外,当<code>--raw</code>或<code>--numstat</code>已经给出,请勿使用路径名并将 NUL 用作输出字段终止符。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>如果没有这个选项,带有“不寻常”字符的路径名将按照配置变量的说明引用<code>core.quotePath</code>(请参阅 git-config [1])。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--name-only</p></div></div><div class="doc-postil"><div class="c-markdown"><p>仅显示已更改文件的名称。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--name-status</p></div></div><div class="doc-postil"><div class="c-markdown"><p>仅显示已更改文件的名称和状态。有关<code>--diff-filter</code>状态字母的含义,请参阅选项说明。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--submodule=<format></p></div></div><div class="doc-postil"><div class="c-markdown"><p>指定如何显示子模块中的差异。指定使用<code>--submodule=short</code>的<code>short</code>格式时。这种格式只显示范围开始和结束处的提交名称。当<code>--submodule</code>或者<code>--submodule=log</code>被指定时,使用<code>log</code>格式。这种格式列出了像 git-submodule [1] <code>summary</code>那样的提交。当<code>--submodule=diff</code>指定时,使用<code>diff</code>格式。这种格式显示了提交范围内子模块内容变化的内联比较。如果配置选项未设置,则默认为<code>diff.submodule</code>或<code>short</code>格式。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--color=<when></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示有色差异。<code>--color</code>(即没有<code>=<when></code>)是一样的<code>--color=always</code>。<code><when></code>可以是一个<code>always</code>,<code>never</code>或<code>auto</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-color</p></div></div><div class="doc-postil"><div class="c-markdown"><p>关闭有色差异。它和<code>--color=never</code>一样。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--word-diff=<mode></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示一个单词 diff,使用<mode>分隔已更改的单词。默认情况下,单词由空格分隔; 见<code>--word-diff-regex</code>下文。<mode>默认为<code>plain</code>,并且必须是以下之一:</p></div></div><div class="doc-postil"><div class="c-markdown"><p>color</p></div></div><div class="doc-postil"><div class="c-markdown"><p>仅使用颜色突出显示更改的词。意味着<code>--color</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>plain</p></div></div><div class="doc-postil"><div class="c-markdown"><p>将单词显示为<code>[-removed-]</code>和<code>{+added+}</code>。如果输入中出现分隔符,则不会尝试跳过分隔符,因此输出可能不明确。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>porcelain</p></div></div><div class="doc-postil"><div class="c-markdown"><p>使用专门用于脚本消费的基于行的格式。以通常的统一差异格式打印已添加/已删除/未更改的运行,以行开头处的<code>+</code>/ <code>-</code>/字符开始并延伸至行尾。输入中<code>~</code>的换行符通过它自己的一行代字符表示。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>none</p></div></div><div class="doc-postil"><div class="c-markdown"><p>再次禁用字差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>请注意,尽管第一个模式的名称,如果启用,颜色将用于突出显示所有模式中更改的部分。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--word-diff-regex=<regex></p></div></div><div class="doc-postil"><div class="c-markdown"><p>使用<regex>来决定一个单词是什么,而不是将非空白的运行视为一个单词。也意味着<code>--word-diff</code>除非已经启用。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>每个<regex>的非重叠匹配都被视为一个单词。为了找到差异,这些匹配之间的任何内容都被认为是空白并被忽略(!)。你可能想追<code>|[^[:space:]]</code>加到你的正则表达式,以确保它匹配所有非空白字符。包含换行符的匹配在换行符处被无提地截断(!)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>例如,<code>--word-diff-regex=.</code>将每个字符看作单词,并相应地逐个字符地显示差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>正则表达式也可以通过 diff 驱动程序或配置选项来设置,请参阅 gitattributes [5]或 git-config [1]。明确给予它覆盖任何 diff 驱动程序或配置设置。差异驱动程序覆盖配置设置</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--color-words=<regex></p></div></div><div class="doc-postil"><div class="c-markdown"><p>相当于<code>--word-diff=color</code>加(如果指定了正则表达式)<code>--word-diff-regex=<regex></code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-renames</p></div></div><div class="doc-postil"><div class="c-markdown"><p>关闭重命名检测,即使配置文件提供了默认设置。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--check</p></div></div><div class="doc-postil"><div class="c-markdown"><p>警告如果更改引入冲突标记或空白错误。认为空白错误是由<code>core.whitespace</code>配置控制的。默认情况下,尾随空格(包括单独由空格组成的行)和空格字符(紧跟该行的初始缩进内的制表符后面的空格字符)将被视为空白错误。如果发现问题,则退出非零状态。与--exit-code 不兼容。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ws-error-highlight=<kind></p></div></div><div class="doc-postil"><div class="c-markdown"><p>突出显示空白的错误<code>context</code>,<code>old</code>或者<code>new</code>把差异线。多个值以逗号分隔,<code>none</code>重置以前的值,<code>default</code>将列表重置为<code>new</code>和<code>all</code>简写为<code>old,new,context</code>。如果未给出此选项,并且<code>diff.wsErrorHighlight</code>未设置配置变量,则只会<code>new</code>突出显示行中的空白错误。空白错误是彩色的<code>color.diff.whitespace</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--full-index</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在生成补丁格式输出时,在“索引”行上显示完整的映像前和映像后blob对象名称,而不是第一批字符。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--binary</p></div></div><div class="doc-postil"><div class="c-markdown"><p>除了<code>--full-index</code>,输出可以应用<code>git-apply</code>的二进制差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--abbrev=<n></p></div></div><div class="doc-postil"><div class="c-markdown"><p>不是在 diff-raw 格式输出和 diff-tree 标题行中显示完整的40字节十六进制对象名称,只显示部分前缀。这与<code>--full-index</code>上面的选项无关,后者控制 diff-patch 输出格式。非默认的位数可以用指定<code>--abbrev=<n></code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-B<n> --break-rewrites[=<n>]</p></div></div><div class="doc-postil"><div class="c-markdown"><p>将完全重写更改分解为删除和创建对。这有两个目的:</p></div></div><div class="doc-postil"><div class="c-markdown"><p>它影响到一种改变的方式,这种改变相当于整个文件的重写,而不是像一系列删除和插入混合在一起,只有几行文本与上下文相匹配,但是作为一个单一的删除旧的一切,随后是一个单次插入所有新事物,并且数字<code>m</code>控制-B 选项的这个方面(默认为60%)。<code>-B/70%</code>指定只有少于30%的原始数据应保留在 Git 的结果中,以便将其视为全部重写(否则结果补丁将是一系列与上下文行混合的删除和插入)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>与-M 一起使用时,完全重写的文件也被认为是重命名的来源(通常-M仅考虑作为重命名源消失的文件),并且该数字<code>n</code>控制着-B 选项的这个方面(默认为50%)。<code>-B20%</code>指定添加和删除相对于文件大小的20%或更多的更改有资格作为可能的重命名源到另一个文件。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-M<n> --find-renames=<n></p></div></div><div class="doc-postil"><div class="c-markdown"><p>如果生成差异,则检测并报告每次提交的重命名。在遍历历史记录时跨越重命名后续文件,请参阅<code>--follow</code>。如果<code>n</code>被指定,则它是相似度指数的阈值(即与文件大小相比的添加/删除量)。例如,<code>-M90%</code>如果超过90%的文件没有改变,Git 应该考虑删除/添加对是一个重命名。如果没有<code>%</code>符号,该数字应作为分数读取,并在其前面加小数点。即,<code>-M5</code>变成0.5,并且因此是相同的<code>-M50%</code>。同样的,<code>-M05</code>也是一样的<code>-M5%</code>。要将检测限制为精确重命名,请使用<code>-M100%</code>。默认相似度指数为50%。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-C<n> --find-copies=<n></p></div></div><div class="doc-postil"><div class="c-markdown"><p>检测副本以及重命名。另见<code>--find-copies-harder</code>。如果<code>n</code>被指定,它的含义与<code>-M<n></code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--find-copies-harder</p></div></div><div class="doc-postil"><div class="c-markdown"><p>出于性能原因,默认情况下,<code>-C</code>只有当副本的原始文件在相同的变更集中被修改时,选项才会查找副本。该标志使命令检查未修改的文件作为复制源的候选项。对于大型项目来说,这是一项非常昂贵的操作,因此请谨慎使用。给予多个<code>-C</code>选项具有相同的效果。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-D --irreversible-delete</p></div></div><div class="doc-postil"><div class="c-markdown"><p>省略原图像进行删除,即仅打印标题,但不打印原像和之间的差异<code>/dev/null</code>。由此产生的补丁不适用于<code>patch</code>或<code>git apply</code>; 这仅适用于那些想专注于更改后查看文本的人。另外,输出显然缺乏足够的信息来反向应用这样的补丁,即使是手动补丁也是如此,因此也就是选项的名称。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在与<code>-B</code>删除/创建对的删除部分一起使用时,还要省略原图。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-l<num></p></div></div><div class="doc-postil"><div class="c-markdown"><p>在<code>-M</code>和<code>-C</code>选项需要为O(n ^ 2)的处理时间,其中n是/复制目标潜在的重命名的数目。如果重命名/复制目标的数量超过指定的数量,则此选项可防止重命名/复制检测运行。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--diff-filter=[(A|C|D|M|R|T|U|X|B)…*]</p></div></div><div class="doc-postil"><div class="c-markdown"><p>选择仅添加(<code>A</code>),复制(<code>C</code>),删除(<code>D</code>),修改(<code>M</code>),重命名(<code>R</code>),其类型(即常规文件,符号链接,子模块,...)更改(<code>T</code>),Unmerged(<code>U</code>),未知(<code>X</code>)或已配对 Broken(<code>B</code>)。可以使用任何过滤字符的组合(包括无)。当<code>*</code>(全部或无)添加到组合中时,如果有任何文件与比较中的其他条件匹配,则选择所有路径; 如果没有与其他标准匹配的文件,则不会选择任何内容。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>此外,这些大写字母可以降低排除。例如<code>--diff-filter=ad</code>排除添加和删除的路径。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-S<string></p></div></div><div class="doc-postil"><div class="c-markdown"><p>查找改变文件中指定字符串出现次数(即添加/删除)的差异。旨在供剧本使用。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>当你寻找一个精确的代码块(比如一个结构体)并且想知道该块自第一次出现以来的历史记录时,它非常有用:迭代地使用该特征将原始图像中的有趣块返回到<code>-S</code>,并继续前进,直到获得该块的第一个版本。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-G<regex></p></div></div><div class="doc-postil"><div class="c-markdown"><p>寻找补丁文本包含与<regex>匹配的添加/删除行的差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>为了说明之间的区别<code>-S<regex> --pickaxe-regex</code>和<code>-G<regex></code>,考虑在同一个文件中的以下DIFF提交:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash">+ return !regexec(regexp, two->ptr, 1, &regmatch, 0);...- hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><p>虽然<code>git log -G"regexec\(regexp"</code>会显示此提交,但<code>git log -S"regexec\(regexp" --pickaxe-regex</code>不会(因为该字符串的出现次数没有改变)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>有关<code>pickaxe</code>更多信息,请参阅 gitdiffcore [7]中的条目。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--pickaxe-all</p></div></div><div class="doc-postil"><div class="c-markdown"><p>当<code>-S</code>或<code>-G</code>发现更改时,显示该更改集中的所有更改,而不仅仅是包含<string>中的更改的文件。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--pickaxe-regex</p></div></div><div class="doc-postil"><div class="c-markdown"><p>将给定的<string> <code>-S</code>视为扩展的POSIX正则表达式进行匹配。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-O<orderfile></p></div></div><div class="doc-postil"><div class="c-markdown"><p>控制文件在输出中出现的顺序。这覆盖了<code>diff.orderFile</code>配置变量(请参阅git-config [1])。取消<code>diff.orderFile</code>,使用<code>-O/dev/null</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>输出顺序由<orderfile>中的全局模式顺序决定。所有具有与第一个模式相匹配的路径名的文件将首先输出,接下来将输出所有具有匹配第二个模式(但不是第一个)的路径名的文件,依此类推。最后输出所有不匹配任何模式的路径名的文件,就好像文件末尾有一个隐含的匹配模式一样。如果多个路径名具有相同的排名(它们匹配相同的模式但没有更早的模式),则它们的输出顺序相对于彼此是正常顺序。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>按以下方式解析<orderfile>:</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p>空白行被忽略,所以它们可以用作分隔符以提高可读性。</p></li><li><p>以散列(“ <code>#</code>”)开头的行会被忽略,因此它们可以用于注释。如果以散列开头,则在模式的开头添加反斜杠(“ <code>\</code>”)。</p></li><li><p>每隔一行包含一个模式。</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>模式与没有 FNM_PATHNAME 标志的 fnmantch(3)使用的模式具有相同的语法和语义,但如果删除任何数量的最终路径名组件都与模式匹配,则路径名也与模式匹配。例如,模式“ <code>foo*bar</code>”匹配“ <code>fooasdfbar</code>”和“ <code>foo/bar/baz/asdf</code>”但不是“ <code>foobarx</code>”。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-R</p></div></div><div class="doc-postil"><div class="c-markdown"><p>交换两个输入; 即显示索引或磁盘文件与树内容的差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--relative=<path></p></div></div><div class="doc-postil"><div class="c-markdown"><p>当从项目的子目录运行时,可以通过该选项告知排除目录外的更改并显示与其相关的路径名。如果不在子目录中(例如,在裸存储库中),可以通过给出<path>作为参数来命名将哪个子目录作为输出的相对位置。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-a --text</p></div></div><div class="doc-postil"><div class="c-markdown"><p>将所有文件视为文本。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ignore-space-at-eol</p></div></div><div class="doc-postil"><div class="c-markdown"><p>忽略 EOL 中的空白变化。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-b --ignore-space-change</p></div></div><div class="doc-postil"><div class="c-markdown"><p>忽略空白量的变化。这会忽略行结束处的空白,并认为一个或多个空白字符的所有其他序列是等价的。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-w --ignore-all-space</p></div></div><div class="doc-postil"><div class="c-markdown"><p>比较行时忽略空格。即使一行有空白,而另一行没有空白,这也会忽略差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ignore-blank-lines</p></div></div><div class="doc-postil"><div class="c-markdown"><p>忽略其行全部空白的更改。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--inter-hunk-context=<lines></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示差异 hunk 之间的上下文,直到指定的行数,从而融合彼此接近的hunk。如果配置选项未设置,则默认为<code>diff.interHunkContext</code>或0。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-W --function-context</p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示整个周围的变化功能。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ext-diff</p></div></div><div class="doc-postil"><div class="c-markdown"><p>允许执行一个外部比较助手。如果你用 gitattributes [5]设置外部差异驱动程序,你需要在 git-log [1]和朋友中使用这个选项。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-ext-diff</p></div></div><div class="doc-postil"><div class="c-markdown"><p>禁止外部差异驱动程序。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--textconv --no-textconv</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在比较二进制文件时,允许(或不允许)运行外部文本转换过滤器。有关详细信息,请参阅 gitattributes [5]。由于 textconv 过滤器通常是单向转换,因此生成的差异适合人类消费,但无法应用。出于这个原因,默认情况下,textconv 过滤器仅针对 git-diff [1]和 git-log [1]启用,但不适用于 git-format-patch [1]或 diff plumbing命令。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ignore-submodules=<when></p></div></div><div class="doc-postil"><div class="c-markdown"><p>忽略差异代中子模块的更改。<when>可以是“none”,“untracked”,“dirty”或“all”,这是默认设置。如果子模块包含未跟踪或已修改的文件,或者 HEAD 与超级项目中记录的提交不同,并且可用于覆盖 git-config [1]或 gitmodules [5]中的任何<code>ignore</code>选项设置,则使用“none” ]。当使用“未跟踪”时,如果子模块仅包含未跟踪内容(但仍然针对修改内容进行扫描),则子模块不会被认为是脏的。使用“dirty”会忽略对子模块工作树的所有更改,只会显示超级项目中存储的提交更改(这是1.7.0之前的行为)。使用“全部”</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--src-prefix=<prefix></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示给定的源前缀而不是“a /”。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--dst-prefix=<prefix></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示给定的目的地前缀而不是“b /”。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--no-prefix</p></div></div><div class="doc-postil"><div class="c-markdown"><p>不要显示任何来源或目的地前缀。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--line-prefix=<prefix></p></div></div><div class="doc-postil"><div class="c-markdown"><p>为每行输出添加一个额外的前缀。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>--ita-invisible-in-index</p></div></div><div class="doc-postil"><div class="c-markdown"><p>默认情况下,由“git add -N”添加的条目显示为“git diff”中的现有空文件和“git diff --cached”中的新文件。这个选项使条目在“git diff”中显示为新文件,在“git diff --cached”中不存在。这个选项可以恢复<code>--ita-visible-in-index</code>。这两个选项都是实验性的,可以在将来删除。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>有关这些常用选项的更详细的解释,请参阅 gitdiffcore [7]。</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>用-p生成补丁</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>当使用选项运行“git-diff-index”,“git-diff-tree”或“git-diff-files”时,不带<code>-p</code>选项运行“git diff” <code>--raw</code>,使用“-p”运行“git log”选项,它们不会产生上述输出; 相反,他们生成一个补丁文件。您可以通过<code>GIT_EXTERNAL_DIFF</code>和<code>GIT_DIFF_OPTS</code>环境变量自定义这些修补程序的创建。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>-p选项产生的东西与传统的diff格式略有不同:</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>它前面有一个“git diff”头文件,它看起来像这样:diff --git a / file1 b / file2</p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><p>在<code>a/</code>和<code>b/</code>文件名是,除非重命名/副本所涉及的相同。尤其是,即使是创建或删除,<code>/dev/null</code>也可<code>not</code>用于替换文件名<code>a/</code>或<code>b/</code>文件名。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>当重命名/复制参与,<code>file1</code>和<code>file2</code>示出了重命名/复制的源文件的名称和重命名/复制分别产生,该文件的名称。</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>它后跟一个或多个扩展标题行:旧模式<mode>新模式<mode>已删除文件模式<mode>新文件模式<mode>从<path>复制到<path>从<path>重命名重命名为<path>相似索引<number>不相似索引<number>索引<hash> .. <hash> <mode></p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><p>文件模式打印为6位八进制数字,包括文件类型和文件权限位。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>扩展标题中的路径名称不包含<code>a/</code>和<code>b/</code>前缀。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>相似性指数是未改变的行的百分比,不相似性指数是改变的行的百分比。它是一个向下舍入的整数,后面跟着一个百分号。100%的相似性指数值因此被保留给两个相同的文件,而100%相异性意味着来自旧文件的行不会将其转换为新的文件。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>索引行包含更改前后的 SHA-1校验和。如果文件模式没有改变,则包含<mode>; 否则,单独的行表示旧模式和新模式。</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>带有“不常用”字符的路径名将按照配置变量的说明引用<code>core.quotePath</code>(请参阅 git-config [1])。</p></li><li><p><code>file1</code>输出中的所有文件在提交之前引用文件,所有<code>file2</code>文件在提交之后引用文件。将每个更改顺序应用于每个文件是不正确的。例如,这个补丁会将 a 和 b:diff --git a / ab / b重命名为重命名为 b diff --git a / bb / a将重命名从 b 重命名为 a</p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><h2>结合 diff 格式</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>任何 diff-generating 命令都可以使用<code>-c</code>或<code>--cc</code>选项<code>combined diff</code>在显示合并时生成一个。这是显示与 git-diff [1]或 git-show [1]合并时的默认格式。还要注意,您可以<code>-m</code>选择这些命令中的任何一个来强制生成合并的单个父代的差异。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>一个<code>combined diff</code>格式如下:</p></div></div><div class="doc-postil"><div class="c-markdown"><pre><code class="language-Bash">diff --combined describe.c
|
||
|
||
index fabadb8,cc95eb0..4866510--- a/describe.c+++ b/describe.c
|
||
|
||
@@@ -98,20 -98,12 +98,20 @@@ return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; }- static void describe(char *arg) -static void describe(struct commit *cmit, int last_one)++static void describe(char *arg, int last_one) { + unsigned char sha1[20]; + struct commit *cmit;
|
||
|
||
struct commit_list *list; static int initialized = 0;
|
||
|
||
struct commit_name *n; + if (get_sha1(arg, sha1) < 0) + usage(describe_usage); + cmit = lookup_commit_reference(sha1); + if (!cmit) + usage(describe_usage); + if (!initialized) {
|
||
|
||
initialized = 1; for_each_ref(get_name);</code></pre></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>它前面有一个“git diff”头,看起来像这样(当使用<code>-c</code>选项时):diff - 组合文件</p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><p>或者像这样(当使用<code>--cc</code>选项时):</p></div></div><div class="doc-postil"><div class="c-markdown"><p>diff --cc file</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>它后面跟着一个或多个扩展标题行(此示例显示与两个父级合并):index <hash>,<hash> .. <hash> mode <mode>,<mode> .. <mode>新文件模式<mode>删除文件模式<mode>,<mode></p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><p><code>mode <mode>,<mode>..<mode></code>行仅在至少有一个<mode>与其他行不同时出现。具有关于检测到的内容移动(重命名和复制检测)的信息的扩展标头被设计为与两个<tree-ish>的差异一起工作,并且不被组合的差异格式使用。</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>紧接着是两行文件/文件头--- a/file +++ b/file</p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><p>类似于传统<code>unified</code>差异格式的双行标题,<code>/dev/null</code>用于表示创建或删除的文件。</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p>块头格式被修改以防止人们意外地将其提供给<code>patch -p1</code>。组合的差异格式是为了审查合并提交更改而创建的,并不适用于应用。此更改与扩展<code>index</code>标头中的更改类似:@@@ <from-file-range> <from-file-range> <to-file-range> @@@</p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><p>组合 diff 格式的块头中有(双亲数+ 1)个<code>@</code>字符。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>与传统的<code>unified</code>差异格式不同,该格式显示两个文件A和B,其中有一列<code>-</code>(减号 - 出现在 A 中但在 B 中删除),<code>+</code>(加 - 在 A 中丢失,但添加到 B 中)或<code>" "</code>(空格 - 不变)前缀,这种格式将两个或多个文件 file1,file2,...与一个文件X进行比较,并显示 X 与每个 fileN 的不同之处。每个 fileN 的一列都被预置在输出行中,以指出X的行与其不同。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>N列中的字<code>-</code>符表示该行出现在 fileN 中,但不出现在结果中。N列中的<code>+</code>字符表示该行出现在结果中,而 fileN 没有该行(换句话说,从该父母的角度来看,该行被添加)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在上面的输出示例中,函数签名已从两个文件中更改(因此file1和file2中的两个<code>-</code>删除,以及<code>++</code>意味着已添加的一行不会出现在 file1或 file2中)。还有八个其他行与 file1相同,但不会出现在 file2中(因此前缀为<code>+</code>)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>在显示时<code>git diff-tree -c</code>,它将合并提交的父项与合并结果进行比较(即
|
||
|
||
file1..fileN为父项)。如图所示<code>git diff-files -c</code>,它将两个未解决的合并父项与正在运行的树文件进行比较(即 file1为阶段2 aka“我们的版本”,file2为阶段3 aka“他们的版本”)。</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>示例</h2></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log --no-merges</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示整个提交历史记录,但跳过任何合并</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log v2.6.12.. include/scsi drivers/scsi</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示自版本以来<code>v2.6.12</code>更改<code>include/scsi</code>或<code>drivers/scsi</code>子目录中的任何文件的所有提交</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log --since="2 weeks ago" -- gitk</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>在过去的两周内向文件显示更改<code>gitk</code>。“ - ”是避免与名称<strong>分支</strong>混淆的必要条件<code>gitk</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log --name-status release..test</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示“test”分支中但尚未位于“release”分支中的提交以及每个提交修改的路径列表。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log --follow builtin/rev-list.c</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示更改的提交<code>builtin/rev-list.c</code>,包括文件被赋予其当前名称之前发生的提交。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log --branches --not --remotes=origin</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示任何本地分支中的所有提交,但不包含任何远程跟踪分支中的提交<code>origin</code>(您拥有该来源的分支)。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log master --not --remotes=*/master</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示本地主服务器中的所有提交,但不显示任何远程资源库主分支中的提交。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log -p -m --first-parent</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示历史记录,包括变化差异,但仅从“主分支”角度看,跳过来自合并分支的提交,并显示由合并引入的变化的完全差异。这只有在遵循严格的合并所有主题分支的策略时才有意义。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log -L '/int main/',/^}/:main.c</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示<code>main()</code>文件中的<code>main.c</code>功能随着时间的推移如何演变。</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>git log -3</code></p></div></div><div class="doc-postil"><div class="c-markdown"><p>限制显示的提交数量为3。</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>讨论</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>Git 在某种程度上是字符编码不可知的。</p></div></div><div class="doc-postil"><div class="c-markdown"><ul class="ul-level-0 list-paddingleft-2" style="margin: 10px 0px 10px 20px;"><li><p>blob 对象的内容是未解释的字节序列。在核心层面没有编码翻译。</p></li><li><p>路径名以 UTF-8标准化形式 C 编码。这适用于树对象,索引文件,ref 名称,以及命令行参数,环境变量和配置文件中的路径名<code>.git/config</code>(请参阅 git-config [1]) ,gitignore [5],gitattributes [5]和 gitmodules [5])。请注意,核心级 Git 将路径名视为非 NUL 字节序列,不存在路径名编码转换(Mac 和 Windows除外)。因此,即使在使用传统扩展 ASCII编码的平台和文件系统上,使用非 ASCII路径名也可以工作。但是,在这样的系统上创建的存储库在基于 UTF-8的系统(例如 Linux,Mac,Windows)上无法正常工作,反之亦然。此外,许多基于 Git 的工具只是假设路径名称为 UTF-8,并且无法正确显示其他编码。</p></li><li><p>提交日志消息通常以 UTF-8编码,但也支持其他扩展 ASCII编码。这包括
|
||
|
||
ISO-8859-x,CP125x和许多其他版本,但<code>not</code>UTF-16/32,EBCDIC 和 CJK 多字节编码(GBK,Shift-JIS,Big5,EUC-x,CP9xx等)。</p></li></ul></div></div><div class="doc-postil"><div class="c-markdown"><p>虽然我们鼓励提交日志消息使用 UTF-8编码,但核心和 Git 瓷器(Porcelain)都设计为不强制项目使用 UTF-8。如果特定项目的所有参与者发现使用遗留编码更方便,Git 不会禁止它。但是,有几件事要牢记。</p></div></div><div class="doc-postil"><div class="c-markdown"><ol class="ol-level-0 list-paddingleft-2"><li><p><code>git commit</code>和<code>git commit-tree</code>如果提交给它的提交日志消息看起来不像一个有效的 UTF-8字符串,则会发出警告,除非您明确声明您的项目使用了旧版编码。说这个的方法是在<code>.git/config</code>文件中有 i18n.commitencoding ,像这样:i18n commitEncoding = ISO-8859-1</p></li></ol></div></div><div class="doc-postil"><div class="c-markdown"><p>使用上述设置创建的提交对象记录<code>i18n.commitEncoding</code>其<code>encoding</code>标题中的值。这是为了帮助稍后看到他们的其他人。缺少这个头部意味着提交日志消息以UTF-8编码。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>2. <code>git log</code>,<code>git show</code>,<code>git blame</code>和看起来像<code>encoding</code>一个提交对象的报头,并且尝试除非另有规定重新代码日志消息转换成 UTF-8。您可以<code>i18n.logOutputEncoding</code>在<code>.git/config</code>文件中指定所需的输出编码,如下所示:i18n logOutputEncoding = ISO-8859-1</p></div></div><div class="doc-postil"><div class="c-markdown"><p>如果您没有此配置变量,<code>i18n.commitEncoding</code>则会使用该值。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>请注意,在提交对象级别强制使用 UTF-8时,我们故意选择不重新编写提交日志消息,因为重新编码为 UTF-8不一定是可逆操作。</p></div></div><div class="doc-postil"><div class="c-markdown"><h2>组态</h2></div></div><div class="doc-postil"><div class="c-markdown"><p>关于核心变量,请参阅 git-config [1],关于 diff 生成的设置,请参阅 git-diff [1]。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>format.pretty</p></div></div><div class="doc-postil"><div class="c-markdown"><p><code>--format</code>选项的默认值。(请参阅上文<code>Pretty Formats</code>。)默认为<code>medium</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>i18n.logOutputEncoding</p></div></div><div class="doc-postil"><div class="c-markdown"><p>显示日志时使用编码。(请参阅<code>Discussion</code>上文。)如果设置默认的值为<code>i18n.commitEncoding</code>,否则为 UTF-8。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>log.date</p></div></div><div class="doc-postil"><div class="c-markdown"><p>人可读日期的默认格式。(比较<code>--date</code>选项。)默认为“默认”,这意味着要写日期<code>Sat May 8 19:35:34 2010 -0500</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>log.follow</p></div></div><div class="doc-postil"><div class="c-markdown"><p>如果<code>true</code>,<code>git log</code>将作为如果<code>--follow</code>选项当单个<path>在给定的使用。这与<code>--follow</code>具有相同的限制,即它不能用于跟踪多个文件,并且在非线性历史记录上不能很好地工作。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>log.showRoot</p></div></div><div class="doc-postil"><div class="c-markdown"><p>如果<code>false</code>,<code>git log</code>和相关的命令将不会把最初的承诺作为一个大的创建事件。在<code>git log -p</code>输出中的任何根提交将显示没有附加差异。默认是<code>true</code>。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>log.showSignature</p></div></div><div class="doc-postil"><div class="c-markdown"><p>如果<code>true</code>,<code>git log</code>和相关命令将充当如果<code>--show-signature</code>选项被传递给他们。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>mailmap.*</p></div></div><div class="doc-postil"><div class="c-markdown"><p>参见 git-shortlog [1]。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>notes.displayRef</p></div></div><div class="doc-postil"><div class="c-markdown"><p>除了由<code>core.notesRef</code>或者<code>GIT_NOTES_REF</code>设置的缺省值之外,还引用了在用<code>log</code>命令系列显示提交消息时的注释。参见 git-notes [1]。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>可能是一个未缩写的参考名称或 glob,可能会多次指定。对于不存在的 ref,将发出警告,但不匹配任何 ref 的 glob 默默无视。</p></div></div><div class="doc-postil"><div class="c-markdown"><p>该设置可以通过该<code>--no-notes</code>选项禁用,由<code>GIT_NOTES_DISPLAY_REF</code>环境变量覆盖并由<code>--notes=<ref></code>选项覆盖。</p></div></div></div> |