Git log up to a certain commit

Viewed 2663

I know it's possible to use git log to get commit history between two commits, between two dates, since a date, before a date, and so on..but I've yet to see a way to get a log up to a certain commit.

I know this probably doesn't exist because of the problem of having multiple commits with the same parent/no parent (hard to find the definitive first commit), but is there a workaround?

I've been doing this...

Get the first commit: FIRST_COMMIT=git rev-list HEAD | tail -n 1

Get between first and commit I want git log FIRST_COMMIT..ff353d1

But is there a better way? Like using from the beginning of time up unto the time of the commit I want to use?

2 Answers

Consider a history where A is a more recent commit than B. If I want a log from A to B inclusive, git log <commit A>...<commit B>~1 does the trick (on git version 2.21.0).

Related