【问题标题】:what does git log --graph --all --pretty= do?git log --graph --all --pretty= 做什么?
【发布时间】:2017-05-02 07:41:52
【问题描述】:

我的目标是在没有任何提交细节的情况下打印 git log --graph。从而使其尽可能紧凑。

所以我创建了一个测试存储库并测试了各种输出。 我试了一下,发现--pretty= 参数没有打印任何提交细节(这是我想要的)。但这也让人难以理解。

$ git log --graph --all --pretty=oneline

* 7387eb7a4c5e29f027b0f1cd3077b7ddb5ecf7fd 2nd commit in secBranch
* a5fc3b06605baf0e0d9bcf07da3b8cc849dabf35 first commit in secBranch
| * 7df665d9ed006e3271a506a4f688af4d69ef1f28 first master commit after branching
|/  
* 44b64f360018e241bfabb65ec172c653fff9ca95 this commmit will be branched
* 50123a9e38e65e2ab97d07d3ad0621b099091ffa initial commit
* 1b133613e6194250f8a0a96f68fa907463d57e8d initial commit

加上--pretty= 选项,它变成了

$ git log --graph --all --pretty=

* * | * 
|/  * * * 

有人可以解释一下我在这两个输出中缺少的相似之处吗?

The link for my test repository

【问题讨论】:

  • --pretty=<format string> 是格式化输出。至少,使用--pretty=%h 来显示每个 * 代表的提交。 %h 是哈希值缩写形式的占位符。如果format string 为空,则输出当然是奇怪的。但是在我的机器上,使用--pretty= 就像没有--pretty 一样。
  • --pretty 是一个格式化指令,显然留下={empty string} 不是开发人员预期的情况,git 将其解释为“为每个提交打印一个空的描述字符串”。删除=(文档说这将等于=medium);阅读git help log 以获得更多帮助。

标签: git terminal


【解决方案1】:

我现在明白了。这个输出本质上是一个没有任何提交细节的普通图。它看起来很奇怪,因为它缺少下一行字符以及其他细节。

这个命令修复了它。

$ git log --graph --oneline --all --pretty=%n

*
|
*
|
| *
|/
|
*
|
*
|
*

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-18
    • 1970-01-01
    • 2021-03-26
    相关资源
    最近更新 更多