Reputation: 983
I have such a commit
commit 8a183536da1641afa6bd5a27ae391b387b7cd052
Author: hidden
AuthorDate: Fri Sep 7 10:13:59 2012
Commit: hidden
CommitDate: Fri Dec 7 17:29:24 2012
I want to filter the log and show the commit by AuthorDate.
I tried --since
& --until
options, but it actually filter the CommitDate.
That means I can only get the commit by
git log --since='2012-12-01' --until='2012-12-10'
If I want to get the commit filter by start_date '2012-09-01' and end_date '2012-09-10'
Any tips?
Upvotes: 46
Views: 17951
Reputation: 2660
I sometimes want to find the commits authored by me on a certain date. For that I use git log --all --author=jpo --format="%ai %s" |grep -E ^2015-09-01
. Unfortunately that approach wont work for filtering by date range in general but for the range used in the question it could be easily done: git log --all --author=jpo --format="%ai %s" |grep -E ^2012-12-(0.|10)
If you want more information about the commits besides author date and commit message just add more parameters to the format string (check the PRETTY FORMATS section of the git help log
page).
Upvotes: 3
Reputation: 12675
I'm afraid you need to do some scripting:
git log --format="%ad %H" --date=iso | sort | ruby -ane 'date = $F[0] ; hash = $F[3] ; puts hash if ("2013-08-23".."2013-09-26").cover?(date)'
gave to me:
3eddb854eaea971e9a60147153f0f3c9be4f1a5a dfeefd4715c4fddef0957c5aff238c525bb1def6 db654badb97f3784286171d4645e9face6a42865 62cdba07e6ae0cd28752491a83f584d3e18a5619 7643a0458a54200f8944583d66c089d63c1bf688 23b720852a36e959d0f45f9d11f05d4aa7ee0cb9 f729ec9c5bf37ee0284a8db47cbc79a0b53145bb bc2d647ae86fbff1246ba163a5a99d25ed2f3523 a0752b3cbae39698449be953153ddaafe35c054c 8e88fffc75cbdda333c86cb4f5eb9b5b30263c27
Unfortunately, git log 3eddb854eaea971e9a60147153f0f3c9be4f1a5a..8e88fffc75cbdda333c86cb4f5eb9b5b30263c27
is not guaranteed to work because those commits may be in different branches.
Let's explain what I did:
--format="%ad %H"
– format log as author_date commit_hash
lines--date=iso
– dates in YY-mm-dd HH:MM:SS
formatsort
– Unix command which sorts lines alphabetically; it's suitable to sort dates in ISO formatruby -ane
– execute ruby script. -n means execute for every line, -a split those lines and put fields into $F
array, -e precises script to execute("2011-02-23".."2011-02-26").cover?(date)
– create range from two strings and check if date fits it inclusively (in the meaning of alphabetical order, we were not parsing those dates)I have no idea what to do next (to give you nicer log), but glad to move you to this point.
Upvotes: 9
Reputation: 171
git log --format=format:"%ai %aE %s"
and then grep by AuthorName and/or date!
Upvotes: 16