Charles
Charles

Reputation: 1269

Git : list all commits that are both children of revision A and parents of revision B

Revision A is some days old, revision B some months old. Yet when using git log A..B or git log A...B, I get revisions that are some years old. That makes no sense to me. How do I single out the history of commits that are both children of A and parents of B ?

Upvotes: 0

Views: 34

Answers (1)

Enrico Campidoglio
Enrico Campidoglio

Reputation: 60013

You can use the --ancestry-path option of git log:

--ancestry-path
When given a range of commits to display (e.g. commit1..commit2 or commit2 ^commit1), only display commits that exist directly on the ancestry chain between the commit1 and commit2, i.e. commits that are both descendants of commit1, and ancestors of commit2.

In your case, you would say:

git log --ancestry-path A..B

To get the commits that are both children of A and parents of B.

Upvotes: 1

Related Questions