以下是一个示例脚本,它使用Git命令来检索指定时间段内的提交,并将它们按日期显示出来。
#!/bin/sh
## 设置起始和结束日期
start_date="2022-01-01"
end_date="2022-12-31"
## 在指定时间范围内检索提交
git log --pretty=format:"%h - %an, %ar : %s" --after="$start_date" --before="$end_date" --reverse
在脚本中,我们首先将起始和结束日期存储在变量 start_date
和 end_date
中。然后,我们使用Git log命令来检索在指定时间范围内的提交。
--pretty=format:"%h - %an, %ar : %s"
文本格式定义的每次提交的输出内容。它包括提交哈希值(%h
),作者名(%an
),相对时间(%ar
)和提交信息(%s
)。
--after
和--before
选项用于定义起始和结束日期。
--reverse
命令选项用于在时间倒序中显示提交信息。
运行脚本后,它将按照时间戳顺序显示Git提交记录。