Let's say I have the following history
D---E-------F
/ \ \
B---C---G---H---I---J
/ \
A-------K---------------L--M
git log --ancestry-path D..M will give me
E-------F
\ \
G---H---I---J
\
L--M
However, I would like just the following
E
\
G---H---I---J
\
L--M
Or
E-------F
\
I---J
\
L--M
Essentially, I would like to traverse down only one path, not two.
Is this possible? And if so, what is the command?
Edit:
I've tried using --first-parent, but this isn't exactly it. git log --first-parent G..M gives me
F
\
H---I---J
\
L--M
It includes F, because F is the first parent of I. Instead I'd like
H---I---J
\
L--M
Any help would be appreciated
Solution (that worked for me):
As @VonC stated, there isn't a single one-liner that does this. So I ended up using a bash script.
- For each commit in 'git log --ancestry-path G..M'
- Determine if $commit's parent includes the commit we were previously on
- If yes, continue. do something interesting.
- If no, skip that commit.
For example, git log --first-commit G..M is
H - F - I - J - L - M
However, F's parent is E, not H. So we omit F, giving me
H - I - J - L - M
Yay!