The necessary commits are not observed because HEAD~3
tells git to always follow the first parent in the commit tree, which happens to follow the merged branch history‡, which is, from your question, not the history you are after.
You need to explicitly select between commit^1
and commit^2
(and also commit^3
for octopus merges) to navigate the tree. For your example:
git log --oneline --graph --decorate
* 2e6d3cf HEAD
* 4abe96e HEAD^1 = HEAD~1 (! History branches here. !)
|\
| * 8687f73 HEAD^1^1 = HEAD^^ = HEAD~2
| * eed4f10 HEAD^^^ = HEAD~3
| * d2d58e6 HEAD^^^^ = HEAD~4
* | 34d130d HEAD^2 (! Note !)
|/
* 75b1b6d HEAD^2^ = HEAD^^^^^ = HEAD~5
* 8a3b067 ...
* d856ef1 ...
* 7331f83 ...
‡ The order is a bit unusual here as a merge commit records the parents such that the HEAD at the time of the merge is always the first parent, and that implies that you must have been on the 8687f73 when you've done the merge for it to count as the first.