如何使Git日志显示今天的所有提交?

时间:2011-02-25 03:54:21

标签: git git-log

我希望能够使用git log查看我今天提交的所有提交内容。我想出了git log --after="yesterday"
然而,这对我来说似乎有点尴尬,是否有更简单的命令来达到同样的效果?

6 个答案:

答案 0 :(得分:80)

编辑:由于这是接受的答案我无法删除,所以我在这里张贴@西蒙的回答:

git log --since="6am"

当然,您可以将时间调整到适合您的“早晨”:)

答案 1 :(得分:61)

也许最好是使用

git log --since="6am"

您可以根据自己的需要调整时间;)

答案 2 :(得分:18)

您可以创建别名以缩短此命令

git config --global alias.today 'log --since=7am'

然后执行:

git today

答案 3 :(得分:16)

要获得今天所有的提交...

git log --since=midnight

答案 4 :(得分:4)

不过,这也有效:
git log --since=am

答案 5 :(得分:3)

已经有几个有用的正确答案(例如git log --since="6am")但奇怪的是文档中缺少Git的特殊日期(至少谷歌搜索"yesterday" "noon" site:git-scm.com没有返回结果)。< / p>

有很多方法可以找出可用的内容,例如Specification for syntax of git dates的答案特别有用。在一个Ryan O'Hara points out

it seems to accept all formats that it can output, as described in the documentation for the --date option:

  

--date=(relative|local|default|iso|rfc|short|raw)

     

仅对以人类可读格式显示的日期生效,例如使用时   --prettylog.date config变量设置log的默认值   命令的--date选项。

     

--date=relative显示相对于当前时间的日期,例如&#34; 2小时前&#34;。

     

--date=local在用户的本地时区显示时间戳。

     

--date=iso(或--date=iso8601)以ISO 8601格式显示时间戳。

     

--date=rfc(或--date=rfc2822)以RFC 2822格式显示时间戳,通常位于电子邮件中。

     

--date=short仅以YYYY-MM-DD格式显示日期,但不显示时间。

     

--date=raw以内部原始git格式%s %z格式显示日期。

     

--date=default显示原始时区(提交者或作者)的时间戳。

我最喜欢的答案是from me_and指导我们the git date.c class。向下扫描,你会发现这段代码(在写这篇代码的时候是第925行):

static const struct special {
    const char *name;
    void (*fn)(struct tm *, struct tm *, int *);
} special[] = {
    { "yesterday", date_yesterday },
    { "noon", date_noon },
    { "midnight", date_midnight },
    { "tea", date_tea },
    { "PM", date_pm },
    { "AM", date_am },
    { "never", date_never },
    { "now", date_now },
    { NULL }
};

我绝对使用git log --before=tea,虽然查看了date_tea函数,但我认为他们并未阅读Rupert Brooke

static void date_tea(struct tm *tm, struct tm *now, int *num)
{
    date_time(tm, now, 17);
}
相关问题