【问题标题】:Shorten the refs when using: git log --graph --pretty=oneline --decorate=full --oneline使用时缩短参考: git log --graph --pretty=oneline --decorate=full --oneline
【发布时间】:2014-06-12 21:41:16
【问题描述】:

我正在使用

git log --graph --pretty=oneline --decorate=full --oneline

获取以下提交图:

* 221b95b (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/remotes/upstream/master, refs/heads/master) 格式化提交

但是显示完整的 refs 路径很不方便,因为它太长了。 有没有办法缩短它以使路径缩短如下?:

* 221b95b (HEAD, origin/master, origin/HEAD, upstream/master, master) 格式化提交

【问题讨论】:

  • --oneline 表示--pretty=oneline --abbrev-commit。

标签: git


【解决方案1】:

使用--decorate(默认为short)而不是--decorated=full。

另外--pretty=oneline 是多余的,因为您已经使用了--oneline,这是--pretty=oneline --abbrev-commit 的简写。

最终,只是做

git log --graph --decorate --oneline

结果:

* 73017eb (HEAD, origin/master, master) A commit message

【讨论】:

    【解决方案2】:

    只需使用--decorate 而不是--decorate=full,因为short 是--decorate 的默认值,如git log documentation 所述(我的粗体强调):

    --decorate[=short|full|no]
    

    打印显示的任何提交的引用名称。如果指定了short,则不会打印引用名称前缀refs/heads/、refs/tags/ 和refs/remotes/。如果指定了full,将打印完整的引用名称(包括前缀)。 默认选项是short。

    另外,由于jthill commented,--pretty=oneline 是多余的,因为--oneline 已经在每一行列出了提交:

    --oneline 表示--pretty=oneline --abbrev-commit。

    所以把它们放在一起:

    git log --graph --decorate --oneline
    

    【讨论】:

    • git log --graph --decorate --oneline 完美运行。非常感谢!
    猜你喜欢
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 1970-01-01
    • 2021-10-26
    • 2020-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多