26

I'm trying to get all commits before some date from AOSP (android open source project).
I found that I can do it by git command:
git log --before="2011-12-01"

But it shows me only author date (date when patch or change was uploaded buy not merged/changed)

Also I found that I can get date which I need by next git command:
git log --pretty=format:"%cd"
I't will show commit date.

And the question is:
how can get git log before some commit date?

Laser
  • 6,652
  • 8
  • 54
  • 85
  • 1
    Have your read the [man page for git log](https://www.kernel.org/pub/software/scm/git/docs/git-log.html) and then tried `--pretty=short`? – RedX Oct 01 '13 at 07:52
  • @RedX yes but I don't see difference between git log --before="2011-12-01" --pretty=format:"%ad" git log --before="2011-12-01" --pretty=format:"%cd" – Laser Oct 01 '13 at 08:09
  • What about: `git log --before="2011-12-01" --pretty=short`? – RedX Oct 01 '13 at 08:47

1 Answers1

33

Simply combine the two:

git log --before="2011-12-01" --pretty=format:"%cd"

As shown in "Git log: filter by commit's author date", git log filters by commit date, and the pretty=format will display just that.

From the man page:

Using more options generally further limits the output (e.g. --since=<date1> limits to commits newer than <date1>)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for answer but I don't see difference between @RedX yes but I don't see difference between `git log --before="2011-12-01" --pretty=format:"%ad"` `git log --before="2011-12-01" --pretty=format:"%cd"` and `git log --before="2011-12-01"` but I hope it should be there. – Laser Oct 01 '13 at 08:09
  • @Pepelac probably because the commit and author date are the same (or very close) – VonC Oct 01 '13 at 08:21
  • I hope on it but no see an example here http://pastebin.com/33pU7Ejp %ad does not affect on `git log` – Laser Oct 01 '13 at 09:16
  • 2
    Interestingly enough, `--before` works like something that would be called `--before-or-on`. – Panzercrisis Nov 23 '20 at 16:35