Strange behavior from git log - how

I have a test repository with 18 commits. git log | grep Date: git log | grep Date: returns the following:

 Date: Fri Sep 20 08:04:13 2013 +0200 Date: Fri Sep 20 08:03:28 2013 +0200 Date: Fri Sep 20 08:02:05 2013 +0200 Date: Thu Sep 19 09:53:10 2013 +0200 Date: Wed Sep 18 17:04:41 2013 +0200 Date: Wed Sep 18 17:03:36 2013 +0200 Date: Sat Sep 14 14:42:10 2013 +0200 Date: Wed Sep 11 10:37:25 2013 +0200 Date: Fri Aug 30 13:59:43 2013 +0200 Date: Fri Aug 30 13:56:35 2013 +0200 Date: Fri Aug 30 11:30:17 2013 +0200 Date: Thu Aug 29 13:44:28 2013 +0200 Date: Thu Aug 29 13:34:32 2013 +0200 Date: Wed Aug 28 14:44:03 2013 +0200 Date: Wed Aug 28 14:32:44 2013 +0200 Date: Tue Aug 27 16:18:53 2013 +0200 Date: Tue Aug 27 16:16:29 2013 +0200 Date: Tue Aug 27 15:46:04 2013 +0200 

I want to get a log from all the commits that occurred today (09/20/2013), so I tried

 git log --since=20-09-2013 | grep Date: 

I do not understand anything. So I searched a bit here for SO and found this question. The comments say that

it seems such that without any time it defaults to the value of the last second of the day.

OK, no problem. Try git log --since=19-09-2013 . It returns

 Date: Fri Sep 20 08:04:13 2013 +0200 Date: Fri Sep 20 08:03:28 2013 +0200 Date: Fri Sep 20 08:02:05 2013 +0200 Date: Thu Sep 19 09:53:10 2013 +0200 

Wait, that seems weird, doesn't it? If he should use the last second of the specified date, why should he display the commit that occurred at 09:53:10 on that date? Should git only display commits that occurred after 09/19/2013?

But wait, it gets even weirder! I tried to add time, resulting in

 git log --since=20-09-201309:00:00 Date: Fri Sep 20 08:04:13 2013 +0200 Date: Fri Sep 20 08:03:28 2013 +0200 Date: Fri Sep 20 08:02:05 2013 +0200 

This trio ... wait a minute ... All commits occurred before 09:00:00 . Why does git display them? In fact, as far as I know, I also made a syntax error! Try to try:

 git log --since=20-09-201312:08:00 | grep Date: Date: Fri Sep 20 08:04:13 2013 +0200 Date: Fri Sep 20 08:03:28 2013 +0200 Date: Fri Sep 20 08:02:05 2013 +0200 

Still working ...

 git log --since=20-09-201312:09:00 | grep Date: <nothing> 

Hmm, what happened there? It seems that git uses only the last two: -segmented numbers. But why does git display commits that occurred after 20.09.2013 08:00 , if it seems like I'm actually looking for a commit after 20.09.201312 08:00 ? That makes no sense to me.

Can someone explain this mess to me? This does not mean that I do not have a solution to solve my problem, but I want to understand what is happening here ...

+6
source share
1 answer

By default, the date in git log will be displayed in the default format.

- date = default shows the timestamps in the original time zone (commiters or authors).

Based on git help system

- date = local shows the timestamps in the local time zone of users.

- date = default shows the timestamps in the original time zone (commiters or authors).

I suggest you run git log --date=local --since=<your date> . It should show all commits in your local computer time.

Now back to your question about --since .

If --since=<date> does not have a specific time, it will use your local time during the execution of this command .

For instance,

 --since "20-09-2013" 

when you run this command at 09 am, it will act as

 --since "20-09-2013 09:00:00" 

So why doesn't he commit some commits that day. (because it has already passed your current time)

if you want to find all commits for today use

 --since "20-09-2013 00:00:00" 

back to the story of mystery

So now git log --since=19-09-2013. What returns

Date: Fri Sep 20 08:04:13 2013 +0200

Date: Fri Sep 20 08:03:28 2013 +0200

Date: Fri Sep 20 08:02:05 2013 +0200

Date: Thu Sep 19 09:53:10 2013 +0200

I think you started this command from 08:04:13 after September 20, 2013. (Based on your hint that when used from today nothing is displayed.).

+11
source

Source: https://habr.com/ru/post/954229/


All Articles