How does git log --since count?

前端 未结 1 1271
温柔的废话
温柔的废话 2020-12-22 22:14

I have a simple test repository with just several commits and want to see the date&time filtered log:

$ git log --author=\"automatix\" --since=\"2013-01-30\"          


        
相关标签:
1条回答
  • 2020-12-22 22:58

    In case it helps someone else who lands here like I did, after a bit of researching I found out that using ISO8601 format also works:

    git log --since="2014-02-12T16:36:00-07:00"
    

    This will give you precision down to the second. Note: you can also use:

    git log --after="2014-02-12T16:36:00-07:00"
    git log --before="2014-02-12T16:36:00-07:00"
    git log --since="1 month ago"
    git log --since="2 weeks 3 days 2 hours 30 minutes 59 seconds ago"
    

    etc.

    Of course, this doesn't "explain why it works so strange." However, it certainly solved the problem for me.


    EDIT:

    After a bit more research, I found out "why it works so strangely":
    It turns out that when you don't specify a date format, git log defaults to either the author's timezone or commit dates, meaning for consistent behavior, it's useful to explicitly declare your date format with something like:

    git log --date=local
    

    Lastly, when you don't specify a time, it defaults to your local time when you ran the command.

    Long story short, being specific should solve the problem:

    git log --date=local --after="2014-02-12T16:36:00-07:00"
    

    Also, you can set the default date format permanently with the following command:

    git config log.date local
    

    you can use any one of these values: (relative|local|default|iso|rfc|short|raw)

    0 讨论(0)
提交回复
热议问题