Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get commits since a particular date in git based on commit date

Tags:

git

git-commit

To get commits after a particular date. I can do this:

git log <ref> --since=<date> --pretty=format:%ci

This seems to list commits based on author date. How do I get commits after a particular date based on commit time ? I can parse the output of above cmd to get what I desire, however I was wondering if there is a better way to do this.

like image 577
Kaushik Lingerkar Avatar asked Jun 08 '15 08:06

Kaushik Lingerkar


People also ask

Does git commit timestamp?

There are actually two different timestamps recorded by Git for each commit: the author date and the commit date. When the commit is created both the timestamps are set to the current time of the machine where the commit was made.

Which command gets the list of commits made in the last 2 weeks?

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.

How do I find the exact time of a commit in git?

Hover over the 'xx days ago' label on the right-hand side, pause and wait for the Tooltip to appear. Hover over the 'xx days ago' label next to the relevant commit under the History tab, pause and wait for the Tooltip to appear.


2 Answers

Your query is not that clear to me but I would like to answer with best of my understanding: as we know, with ref: http://git-scm.com/docs/pretty-formats

%ai: author date, ISO 8601-like format
%ci: committer date, ISO 8601-like format

Is this of any help? Using --after and --before to get results in between. Like below uses same date with results between time (10:36AM to 04:50PM of June 22, 2015) with %ci for committer date

git log --after="2015-06-22T10:36:00-07:00" --before="2015-06-22T16:50:00-07:00" --pretty=format:%ci
like image 99
Jyoti Prakash Avatar answered Oct 19 '22 15:10

Jyoti Prakash


I believe there is no way here to tweak git log here since it is internally implemented to use commit date for before, after, since, until parameters. In general, the default Git's strategy for comparing dates is by commit date.

like image 39
Michał Kalinowski Avatar answered Oct 19 '22 15:10

Michał Kalinowski