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

6

88

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?

Spheroidal answered 25/2, 2011 at 3:54 Comment(0)
E
110

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

Eliseelisee answered 3/3, 2011 at 9:20 Comment(6)
This does not seem to work on git 1.5.6.5, FWIW. I know, old version and all, but I figure this might help someone. git log --after="yesterday" seems to come closest to correct, but it ends up including things that occurred yesterday along with things that occurred after yesterday.Maddox
For me: git log --since="yesterday" works well. Looks nice with --pretty="oneline" too... (git version 1.7.10)Guertin
--since and --after are synonyms, so the answer is suggesting the same thing that is in the question. This will give give the last 24 hours of commits (hence @agentbanks217 problem with seeing commits from yesterday). I have give a different answer below.Siskin
Also, times like "06:00" work, for those that don't like AM/PMSaiva
I had imagined this would work until 5:59am the following day. However, it only lists commits on the same day (i.e., it stops working at midnight)Ochre
Wow, this option is handy yet simple. TIL.Heerlen
F
74

Maybe the best is to use

git log --since="6am"

You can adjust the time to your convenience ;)

Fitly answered 25/2, 2011 at 4:5 Comment(2)
Also add --all to see the log of all branches during the periodFecteau
I voted for this one over the other as it appears to be several days earlier.Automatize
J
29

To get commits from all of today ...

git log --since=midnight
Jughead answered 1/7, 2015 at 5:36 Comment(1)
This command will show commits from today midnight 12AM to 11:59PM right ?Dizen
R
28

You can create alias to shorten this command

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

and then execute:

git today
Realm answered 26/8, 2013 at 8:11 Comment(0)
E
9

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);
}
Emblazonment answered 30/4, 2016 at 11:0 Comment(0)
S
4

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

Stucker answered 5/8, 2014 at 14:4 Comment(1)
Careful though, this is equivalent to --since=noon.Jughead

© 2022 - 2024 — McMap. All rights reserved.