【问题标题】:Git how to view first 8 commits of a repo in one line?Git如何在一行中查看回购的前8个提交?
【发布时间】:2021-02-14 04:22:53
【问题描述】:

我正在使用 windows powershell,我想在一行中查看 repo 的前 8 个提交。

git log --reverse --oneline

显示我想要的,但太多了。我只想要 8 次提交。

git log --reverse --oneline -8

在一行中显示 8 个,但最后 8 个提交,而我想要前 8 个提交。

如何在一行中显示前 8 个提交?

【问题讨论】:

    标签: git command-line-interface git-log


    【解决方案1】:

    试试

    git log --reverse --oneline --pretty=format:'%h %aI | %s%d [%an]' | head -8
    

    --pretty=format:'%h %aI | %s%d [%an]' 是完全可选的,但我喜欢拥有它。 :)

    当然,您也可以将 8 更改为您想查看的任何提交数量。

    【讨论】:

      【解决方案2】:

      这最终奏效了

      git log --reverse --oneline | Select-Object -First 8

      这是使用 syohey 建议的样式的漂亮格式

      git log --reverse --oneline --pretty=format:'%h %aI | %s%d [%an]' | Select-Object -First 8

      head -8 未被识别,我猜 powershell 不支持它。后来,我发现 Select-Object -First 8 是 powershell 对应物,或者至少是我想要的可行解决方案。

      【讨论】:

      • 糟糕!抱歉,我应该提到我使用的系统......不过很高兴你找到了解决方案!
      猜你喜欢
      • 1970-01-01
      • 2014-01-28
      • 2011-05-26
      • 2013-07-07
      • 2023-04-08
      • 2013-11-15
      • 1970-01-01
      • 1970-01-01
      • 2012-02-01
      相关资源
      最近更新 更多