如何让 Git 日志显示所有今天的提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5113425/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make Git log show all of today's commits?
提问by agentbanks217
I want to be able to see all of the commits I made today using git log
. I came up with git log --after="yesterday"
However, that seems a little awkward to me, is there a simpler command to achieve the same effect?
我希望能够看到我今天使用git log
. 我想出了git log --after="yesterday"
然而,这对我来说似乎有点尴尬,有没有更简单的命令来达到同样的效果?
回答by abyx
Edit: Since this is the accepted answer I can't delete it, so I'm posting here @Simon's answer:
编辑:由于这是已接受的答案,我无法删除它,所以我在这里发布@Simon 的答案:
git log --since="6am"
And of course you can adjust the time to whatever is "morning" enough for you :)
当然,您可以将时间调整为对您来说足够“早上”的时间:)
回答by Simon
Maybe the best is to use
也许最好的方法是使用
git log --since="6am"
You can adjust the time to your convenience ;)
您可以根据自己的方便调整时间;)
回答by Dariusz
You can create alias to shorten this command
您可以创建别名来缩短此命令
git config --global alias.today 'log --since=7am'
and then execute:
然后执行:
git today
回答by yoyo
To get commits from allof today ...
要获得今天所有的提交......
git log --since=midnight
回答by dumbledad
There are already several useful correct answers (e.g. git log --since="6am"
) but it is odd that Git's special dates are missing from the documentation (at least googling "yesterday" "noon" site:git-scm.comreturns no results).
已经有几个有用的正确答案(例如git log --since="6am"
),但奇怪的是文档中缺少 Git 的特殊日期(至少谷歌搜索“昨天”“中午”站点:git-scm.com没有返回任何结果)。
There are ways to find out what's available, for example the answers to Specification for syntax of git datesare particularly useful. In one Ryan O'Hara points outthat
有很多方法可以找出可用的内容,例如git 日期语法规范的答案特别有用。瑞恩·奥哈拉 (Ryan O'Hara)在其中之一指出
it seems to accept all formats that it can output, as described in the documentation for the --date option:
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)
Only takes effect for dates shown in human-readable format, such as when using
--pretty
.log.date
config variable sets a default value for log command's--date
option.
--date=relative
shows dates relative to the current time, e.g. "2 hours ago".
--date=local
shows timestamps in user's local timezone.
--date=iso
(or--date=iso8601
) shows timestamps in ISO 8601 format.
--date=rfc
(or--date=rfc2822
) shows timestamps in RFC 2822 format, often found in E-mail messages.
--date=short
shows only date but not time, inYYYY-MM-DD
format.
--date=raw
shows the date in the internal raw git format%s %z
format.
--date=default
shows timestamps in the original timezone (either committer's or author's).
--date=(relative|local|default|iso|rfc|short|raw)
仅对以人类可读格式显示的日期生效,例如使用
--pretty
.log.date
config 变量为 log 命令的--date
选项设置默认值。
--date=relative
显示相对于当前时间的日期,例如“2 小时前”。
--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
显示原始时区(提交者或作者)的时间戳。
My favourite answer there is from me_andwho directs us to the git date.c class. Scan down that and you find this code (at the time of writing it is on line 925):
我最喜欢的答案来自 me_and,他将我们引导至git date.c 类。向下扫描,您会找到以下代码(在撰写本文时,它位于第 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 }
};
I'm definitely using git log --before=tea
, though looking at the date_tea
function I don't think they've read Rupert Brooke:
我肯定在使用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);
}
回答by suzanshakya
Btw, this also works:git log --since=am
顺便说一句,这也有效:git log --since=am