Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git log: filter by commit's author date

Tags:

git

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?

like image 308
atiking Avatar asked Dec 21 '12 09:12

atiking


People also ask

What is author date in git?

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018. Git tracks two dates in commits: author date and commit date. In addition, Azure DevOps Services and TFS track when a commit was first pushed to the server. Author date: when a commit was originally authored.

Which command is used to check last 5 commits by a particular author?

Which command is used to check last 5 commits by a particular author in git? The git shortlog command is a special version of git log intended for creating release announcements. It groups each commit by author and displays the first line of each commit message. This is an easy way to see who's been working on what.

How do you see your git repository's commit history?

The most basic and powerful tool to do this is the git log command. By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first.


2 Answers

git log --format=format:"%ai %aE %s" 

and then grep by AuthorName and/or date!

like image 130
1berto Avatar answered Oct 23 '22 20:10

1berto


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:

  1. --format="%ad %H" – format log as author_date commit_hash lines
  2. --date=iso – dates in YY-mm-dd HH:MM:SS format
  3. sort – Unix command which sorts lines alphabetically; it's suitable to sort dates in ISO format
  4. ruby -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
  5. ("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.

like image 37
skalee Avatar answered Oct 23 '22 21:10

skalee