int(111) int(111) Git查询(统计)一定时间范围内(时间段内)的代码提交的日志和文件 | 绝缘体

Git查询(统计)一定时间范围内(时间段内)的代码提交的日志和文件

 
更多

Git查询(统计)一定时间范围内(时间段内)的代码提交的日志和文件。

显示当前日期(即今天)的提交记录:

$ git log --oneline --since="yesterday"

仅显示某一特定用户(例如,用户 phpernote.com)在今天的提交记录:

$ git log --oneline --since="yesterday" --author="phpernote.com"

还可以显示在某一日期范围内的提交记录。使用以下命令,显示在任意两个日期之间(例如,2022 年 4 月 22 日至 2022 年 4 月 24 日)的提交记录:

$ git log --oneline --since="2022-04-22" --until="2022-04-24"
#since定义起始时间,until定义结束时间。

在上面这个例子中,会输出 2022 年 4 月 22 日至 2022 年 4 月 24 日期间,不包括 2022 年 4 月 22 日的所有提交记录。如果你想要包括 2022 年 4 月 22 日的提交记录,请将命令中的 2022-04-22 替换为 2022-04-21。

查询某用户在2024年4月内的提交记录:

git lg --author=yuhaomiao --since='2024-04-01' --until='2024-04-31'

查询某用户在2024年7月份内的提交记录(不显示 merge 记录,同一天相同的提交内容仅显示一条,按日期升序排列结果):

git log --author=yuhaomiao --since='2024-07-01' --until='2024-08-01' --no-merges --pretty=format:"%ad %s" --date=short | uniq | sort

使用git log命令将提交记录导出为 csv 格式文件:

git log --since='2021-05-21' --until='2021-05-28' --format='%aN' | sort -u | while read name; do echo -en "$name,"; git log --since='2021-05-21' --until='2021-05-28' --author="$name" --numstat --pretty=tformat: --no-merges | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines, %s, removed lines, %s, total lines, %s\n", add, subs, loc }' -; done >> 21_05_28_code.csv;

使用 git log 查询 yhm 用户在指定日期内提交的后缀名为 php 的文件:

git log --author=yhm --stat --no-merges --name-only --since='2024-01-20' --until='2024-01-31' | grep ".php$" | sort | uniq

使用 git log 查询 yhm 用户在指定日期内提交的后缀名为 php 或 css 的文件:

git log --author=yhm --stat --no-merges --name-only --since='2024-01-20' --until='2024-01-31' | grep -E ".php|.css$" | sort | uniq

使用 git log 查询 yhm 用户在一分钟之前提交的后缀名为 php 或 css 的文件:

git log --author=yhm --stat --no-merges --name-only --until=1.minute.ago | grep -E ".php|.css$" | sort | uniq

使用 git log 查询 yhm 用户在近一个小时内提交的后缀名为 php 的文件:

git log --author=yhm --stat --no-merges --name-only --since=1.hour.ago | grep ".php$" | sort | uniq

使用 git log 查询 yhm 用户在近一天内提交的后缀名为 php 的文件:

git log --author=yhm --stat --no-merges --name-only --since=1.day.ago | grep ".php$" | sort | uniq
打赏

本文固定链接: https://www.cxy163.net/archives/2938 | 绝缘体

该日志由 绝缘体.. 于 2024年08月03日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: Git查询(统计)一定时间范围内(时间段内)的代码提交的日志和文件 | 绝缘体
关键字: , , , ,

Git查询(统计)一定时间范围内(时间段内)的代码提交的日志和文件:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter