Assuming the following Git history:
Branch1 B---C-------F---G
/ \ \
Master A-------D---E-------H
Doing a git log master gives the log entries in following order A-B-C-D-E-F-G-H. – but I’m interested in history of master-only (i.e A-D-E-H)
How can I “get rid” of the unwanted log-entries from Branch1? I tried a lot of options for git log, but I cannot find anything appropriate…
This leads to a further thing I don’t understand in this context:
Looking at the log-history given by git log master it shows how my branch master evolved (A-B-C-D-E-F-G-H).
But doing a git checkout HEAD~1 (assuming master=HEAD) gives me E (Evolution HEAD~3:A – HEAD~2:D – HEAD~1:E – HEAD:H -> A-D-E-H)
This is what I don’t understand: the ancestor of H looking at git log is G, while the ancestor of H looking at git checkout is E.
I don’t understand this – What’s the ancestor of H: G or E?…
Conclusion: What I would like to have are git log entries from HEAD to HEAD~n only (for example above n = 1…3).
How can this be achieved? Is it possible at all?
What you’re looking for is
Why that option is called
--first-parentanswers your questionThe answer is: both. E is the first parent, but G is the second parent, because H is a merge commit. A merge commit is one that has more than one parent.