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 litt
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.com returns no results).
There are ways to find out what's available, for example the answers to Specification for syntax of git dates are particularly useful. In one Ryan O'Hara points out that
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.dateconfig variable sets a default value for log command’s--dateoption.
--date=relativeshows dates relative to the current time, e.g. "2 hours ago".
--date=localshows 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=shortshows only date but not time, inYYYY-MM-DDformat.
--date=rawshows the date in the internal raw git format%s %zformat.
--date=defaultshows timestamps in the original timezone (either committer’s or author’s).
My favourite answer there is from me_and who 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):
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:
static void date_tea(struct tm *tm, struct tm *now, int *num)
{
date_time(tm, now, 17);
}
To get commits from all of today ...
git log --since=midnight
Btw, this also works:
git log --since=am
Edit: Since this is the accepted answer I can't delete it, so I'm posting here @Simon's answer:
git log --since="6am"
And of course you can adjust the time to whatever is "morning" enough for you :)
Maybe the best is to use
git log --since="6am"
You can adjust the time to your convenience ;)
You can create alias to shorten this command
git config --global alias.today 'log --since=7am'
and then execute:
git today