【问题标题】:How can I get the Git commits done in the last 3 months counted from the last commit on a branch?从分支上的最后一次提交算起,如何在过去 3 个月内完成 Git 提交?
【发布时间】:2021-09-22 17:08:04
【问题描述】:

我知道,例如与

git shortlog -sn --since=3.months <branch>

现在开始,我可以在&lt;branch&gt; 上完成过去 3 个月内的提交。但是,我怎样才能使3.months&lt;branch&gt; 上的最后一次提交 的日期开始计算呢?是否有语法可以在单个命令中工作,还是需要多次 git 调用?

【问题讨论】:

    标签: git git-log


    【解决方案1】:

    使用git log --format='%ai' &lt;branch&gt; -n1 获取分支上最后一次提交的日期。 date 可以做日期数学,所以用它减去 3 个月。然后将其提供给--since。

    git log --since "$(date --date "$(git log --format='%ai' <branch> -n1) - 3 months")" <branch>
    

    你可能想把它变成一个别名。

    【讨论】:

      猜你喜欢
      • 2012-08-31
      • 2017-06-19
      • 2015-02-13
      • 2022-07-01
      • 2017-12-16
      • 2012-07-24
      • 1970-01-01
      • 2016-01-17
      • 2021-11-28
      相关资源
      最近更新 更多