How to make Git log show all of today's commits?

GitGit Log

Git Problem Overview


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 Solutions


Solution 1 - Git

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 :)

Solution 2 - Git

Maybe the best is to use

git log --since="6am"

You can adjust the time to your convenience ;)

Solution 3 - Git

To get commits from all of today ...

git log --since=midnight

Solution 4 - Git

You can create alias to shorten this command

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

and then execute:

git today

Solution 5 - Git

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.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, in YYYY-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).

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);
}

Solution 6 - Git

Btw, this also works:
git log --since=am

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionab217View Question on Stackoverflow
Solution 1 - GitabyxView Answer on Stackoverflow
Solution 2 - GitSimonView Answer on Stackoverflow
Solution 3 - GityoyoView Answer on Stackoverflow
Solution 4 - GitDariuszView Answer on Stackoverflow
Solution 5 - GitdumbledadView Answer on Stackoverflow
Solution 6 - GitsuzanshakyaView Answer on Stackoverflow