【问题标题】:To color a limited number of lines in git log --oneline在 git log --oneline 中为有限数量的行着色
【发布时间】:2015-08-13 12:48:37
【问题描述】:

当我通过管道将 git 命令发送到 head 以仅显示几十个提交时,颜色会丢失:

git log --oneline | head -50

如何保持有限行数的颜色?

【问题讨论】:

    标签: git head


    【解决方案1】:

    -(n) 仅显示最后 n 次提交

    参考:https://git-scm.com/book/no-nb/v1/Grunnleggende-Git-Viewing-the-Commit-History

    例如

    git log -50 --oneline
    

    【讨论】:

    • 我更喜欢这个,因为它更符合意图
    【解决方案2】:

    Git 检测到您正在使用管道,因此它会禁用颜色,但您可以通过 --color 强制它使用颜色:

    git log --graph --oneline --all --decorate --color | head -50
    

    【讨论】:

      【解决方案3】:

      在你的 git log 命令中使用 -50 作为参数怎么样?

      它将显示最新的 50 个提交。

      你也可以写

      • --max-count=50
      • -n 50
      • -n50
      • -50

      【讨论】:

        猜你喜欢
        • 2018-05-08
        • 1970-01-01
        • 2022-11-16
        • 1970-01-01
        • 1970-01-01
        • 2021-10-26
        • 1970-01-01
        • 2017-09-18
        • 2011-08-18
        相关资源
        最近更新 更多