Reputation: 25782
Consider the following git history (think of C
as master
and X
a feature branch that has merged from master
once):
X
|
M
/|
C E D
|/ /
B /
|/
A
What git log
range revision will give me all the commits that are reachable from X
and include the changes of B
, i.e. B E M X
?
NB: git log B..X
will include D
, which I do not want.
Upvotes: 2
Views: 1565
Reputation: 490078
If the reason to exclude D
is that it is not a descendant of B
,1 consider using --ancestry-path
:
git log --ancestry-path B..X # or git rev-list with the same arguments
This does however exclude B
in the revision walk. To include B
itself is slightly tricky: you have the option of --boundary
, but that sometimes includes too many commits. Another method is to use B^@
to exclude all parents of B
without excluding B
itself. This works whether B
is a regular commit or a merge, and otherwise leaves the --ancestry-path
action undisturbed. It even works if B
is a root commit, though in this case I am not certain that --ancestry-path
is any use.
(If B is an ordinary single-parent commit, git log --ancestry-path B^..X
does the trick and is simpler to think about than B^@
.)
1This is the reason for my comment on the original question about why you intend to exclude D
.
Upvotes: 1