如何让git在作者日期的指定日期范围内显示提交? [英] How to get git to show commits in a specified date range for author date?
问题描述
git log --all --after =< date> 00:00--before =< date> 23:59--author =< author>
根据提交者日期过滤提交。我怎么才能让它显示提交指定的作者日期范围?
你至少不能在Git中单独。 (提醒其他人访问此问题:它不是关于查看作者日期,而是关于选择作者日期的提交, - 在
和之后 - 直到
/ - 在
之前,这些选择器使用提交者日期,而不是作者日期。作为一个极端的例子,它是现在提交的,所以它的提交日期是2000年代,但在作者日期字段中回溯到1999年的某一天。如果您的选择范围是任何时候接近世纪之交,那么您将取消选择此提交,因为其提交者日期为now,更多)我认为这是Git中的一个小错误:您应该可以请求它在任何可以请求它的地方使用作者日期字段使用提交者日期字段。由于我们有%ad
和%cd
,所以使用日志格式化很容易,像,但通过提交选择是不可能的。我们最近的是 git rev-list
可以按作者日期进行排序(在一般的拓扑排序中)。
像 作为一种解决方法,您可以列出所有可能有趣的提交(使用 Apparently this: filters commits based on the committer date. How can I make it show commits for a specified author date range ? You can't—at least, not in Git alone. (Reminder to others visiting this question: it's not about viewing the author date, it's about selecting commits by the author date, a la I consider this a small bug in Git: you should be able to request that it use the author date field anywhere you can request that it use the committer date field. This is easy with log formatting, since we have A global switch in As a workaround, you can list all potentially-interesting commits (with 这篇关于如何让git在作者日期的指定日期范围内显示提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! - use-author-date
这样的 git rev-list
中的全局开关将作为简单的补丁,并不会太难以添加到Git,但我认为最好是 - min-author-age
和 - max-author-age
或类似的,以及按作者日期排序标志(独立于一般 - topo-order
标志,因此 标志的作用与 git rev-list
或同等方式,例如 git log
:除了日期过滤器之外,使用任何说明符使得提交可能有趣,在这种情况下,这只是 - 所有
)并提取他们所有的作者日期字段( git log --format =%at
或其他),然后做自己的修剪的提交ID列表,然后重新提交其余的提交ID到 git log --no-walk
。但这是最好的痛苦。有关更多信息,请参见 Tim Beigeleisen的使用awk 的答案。git log --all --after="<date> 00:00" --before="<date> 23:59" --author="<author>"
--since
/--after
and --until
/--before
. These selectors use the committer date, not the author date. Consider as an extreme example a commit made "now", so that its committer date is in the 2000s, but backdated in the author-date field to some day in the year 1999. If your selection range is "any time near the turn of the century" you'll de-select this commit, since its committer date is "now", more than a decade beyond 1999.)%ad
and %cd
and the like, but impossible with commit selection. The closest we have is that git rev-list
can sort by author-date (within general topo-sorting).git rev-list
, like --use-author-date
, would work as a simple patch, and would not be too hard to add to Git, but I think it would be better to have --min-author-age
and --max-author-age
or similar, and a "sort by author date" flag (independent of the general --topo-order
flag, so that setting both flags has the same effect as --author-date-order
).git rev-list
or equivalent, such as git log
: use whatever specifier makes commits potentially interesting, except for date filters: in this case that's just --all
) and extract all of their author-date fields (with git log --format=%at
or whatever), then do your own pruning of the list of commit IDs, then re-submit the remaining commit IDs to git log --no-walk
. But this is painful at best. See Tim Beigeleisen's answer using awk for more.