如何计算某个日期范围内每个用户的 git 提交?

问题描述 投票:0回答:2

命令

git shortlog -sne
正是我所需要的,但我希望能够指定一个日期范围,而这不是
shortlog
的选项。是否有另一种方法可以在特定日期范围内完成同样的事情?

git
2个回答
130
投票

虽然

git shortlog --help
似乎没有指定它,但
shortlog
采用与
--since
相同的
--after
--before
--until
git log
参数。因此,例如:

git shortlog -sne --since="01 Jan 2024" --before="01 Feb 2024"

注:
这已在 Fedora 21 上运行的 git 2.1.0 和 RHEL 7.1 上运行的 git 1.8.3.1 上得到验证。我手头没有旧系统,但我相信这些参数已经支持了一段时间了。


4
投票

您可以通过两种不同的方式获取一段时间内的提交总数:

第一种方法

使用 [秒 - 小时 - 天 - 周 - 月 - 年] 获取总提交

获取每秒的总提交量

git shortlog -se --count  --since=600.second

获取每分钟的总提交量

git shortlog -se --count  --since=30.minute

获取每日的总提交量

git shortlog -se --count  --since=28.day

获取每周的总提交量

git shortlog -se --count  --since=1.week

按月获取总提交量

git shortlog -se --count  --since=1.month

按年份获取总提交量

git shortlog -se --count --since=2.year

第二种方式

使用“since”和“before”-“since”取开始日期,“before”取您想要从中提交的结束日期。

git shortlog -se --count --since="Dec 1 2021"  --before="Jan 3 2022"
© www.soinside.com 2019 - 2024. All rights reserved.