I need to run git log
to show all commits after a specific date and time, and not leave out any commits, and without running git log
to show all commits, as the latter is too slow (because this should work within git IMO).
However, before you mark this as a duplicate, consider I've read, as carefully as I can, through all of the following:
- What is the format for --date parameter of git commit
- git log --since=<date> options
- Strange behavior from git log --since
- How does git log --since count?
This is what I tried:
$ git --version
git version 2.31.1
$ date
Tue May 18 08:55:45 PDT 2021
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='2021-04-01' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='2021-04-01 00:00' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='2021-04-01 00:00:00' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='2021-04-01T00:00:00' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='1 week ago' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='2 weeks ago' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='3 weeks ago' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='4 weeks ago' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' --since='666 weeks ago' | grep 2021-04- | tail -1
2021-04-23 11:51:30 -0700 4 weeks ago 76044d3f08087add08ad1012ae1ee9a569679268
$ git log --date=local --format='%ad %<(20)%ar %H' --since='2021-04-01' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='2021-04-01 00:00' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='2021-04-01 00:00:00' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='2021-04-01T00:00:00' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='1 week ago' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='2 weeks ago' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='3 weeks ago' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='4 weeks ago' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='666 weeks ago' | grep 2021-04- | tail -1
$ git log --date=local --format='%ad %<(20)%ar %H' --since='666 weeks ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='2021-04-01' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='2021-04-01 00:00' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='2021-04-01 00:00:00' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='2021-04-01T00:00:00' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='1 week ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='2 weeks ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='3 weeks ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='4 weeks ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ad %<(20)%ar %H' --since='666 weeks ago' | grep 2021-04- | tail -1
$ git log --date=iso-local --format='%ad %<(20)%ar %H' | grep 2021-04- | tail -1
2021-04-01 00:00:13 -0700 7 weeks ago 657fa6a40cfd93c6d48a8aee4cc8190df753f6d7
$ git log --date=default --format='%ci %<(20)%ar %H' --since='2021-04-01' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='2021-04-01 00:00' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='2021-04-01 00:00:00' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='2021-04-01T00:00:00' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='1 week ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='2 weeks ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='3 weeks ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='4 weeks ago' | grep 2021-04- | tail -1
$ git log --date=default --format='%ci %<(20)%ar %H' --since='666 weeks ago' | grep 2021-04- | tail -1
2021-04-23 18:51:30 +0000 4 weeks ago 76044d3f08087add08ad1012ae1ee9a569679268
$ git log --date=iso-local --format='%ci %<(20)%ar %H' | grep 2021-04- | tail -1
2021-04-01 00:00:13 -0700 7 weeks ago 657fa6a40cfd93c6d48a8aee4cc8190df753f6d7
$
I'm baffled as to why I get output about commit 76044d3f08087add08ad1012ae1ee9a569679268 at all, and the other --date=something
variations do not show any output. And of course it is wrong output anyhow.
Puzzling.
Here is my slow workaround that I do not want to have to constantly resort to:
$ git log --date=iso-local --format='%ad %<(20)%ar %H' | grep 2021-04- | tail -1
2021-04-01 00:00:13 -0700 7 weeks ago 657fa6a40cfd93c6d48a8aee4cc8190df753f6d7
$
In the latter command, Git is dumping out the entire commit history, only for me to have to filter out the results I am looking for. In this case, git log
is slow because my git repository is huge:
$ git log --date=iso-local --format='%ad %<(20)%ar %H' | wc -l
344841
What am I doing incorrectly here? Or is the --since
option defective?