Question
Using git, is there a built-in command which would give me a sequence of commits, leading from one source commit to a target commit ?
more details
Suppose I have a repo with a history which is a bit intricate :
* 175015a (HEAD -> master) Merge branch 'br1' # target commit
|\
| * bc03512 Merge branch 'br2' into br1
| |\
| | * 077f584 Merge branch 'br3' into br2
| | |\
| | | * 923b15a jjj
| | * | cec6734 iii
| | | * c8259a2 hhh
| | |/
| * | 45cb234 ggg
| | * b1dd3c7 Merge branch 'br3' into br2
| | |\
| | | * 48af382 fff
| | * | 778a504 eee # source commit
| | | * f918010 ddd
| | |/
| | * 9706f28 ccc
| |/
| * 483f665 bbb
|/
* 795fa22 aaa
* fd4bef2 first commit
and that for some reason, I would like to inspect a sequence of commits, which led from commit eee
to the current HEAD
.
I mean a sequence of commits where :
- the first commit is the
target
commit (175015a (master)
in my example) - each commit on line
n+1
is a parent of commit on linen
- the last commit is the
source
commit (778a504 eee
in my example)
With the above example :
# path illustration from the diagram above
175015a * 175015a (HEAD -> master) Merge branch 'br1' # target commit
bc03512 \-* bc03512 Merge branch 'br2' into br1
077f584 \-* 077f584 Merge branch 'br3' into br2
cec6734 * cec6734 iii
b1dd3c7 * b1dd3c7 Merge branch 'br3' into br2
778a504 * 778a504 eee # source commit
would be acceptable.
I am looking for a set of options to pass to git rev-list
or git log
or any other git
command.
things I tried
git log
has a big bunch of options, but I didn't find what I am looking for :
if I run
git log 778a504..master
, it keeps many commits which are not between the two commits (commitsfff
andddd
would be mentioned, for example)if I also add
git log --ancestry-path 778a504..master
, some of the "parasites" commits are dropped, but I still get all the merged branches between the two commits (in the example : I would get bothhhh
andjjj
on one side, andiii
on the other side, I would like to only have one of those two sets of commits)if I use
git log --first-parent 778a504..master
starting frommaster
: I cannot get commits outside the leftmost line in the diagram (I would only getmaster
)some paths are bound to pass through merge commits, so I don't want to exclude them : no
--no-merges
either
note : the answer suggested as duplicate indicates to use --no-merges
and possibly --first-parent
, so it isn't a fit for this question.