Consider the following commit page:
https://github.com/SignalR/SignalR/commit/cc5b002a5140e2d60184de42554a8737981c846c
Typically with Git, a commit is a set of changes applied on top of a previous codebase, so, considering the following tree:

Looking at the diff of 1ca1b6b would show the codebase as of ca2cac9 on the left, and the changes applied in that commit on the right. With a merge commit, what are we seeing on the left hand side? i.e. considering the following tree:

If we view commit 1e25f98 on GitHub, what's on the left? 06f5be1? And what about with a more complicated tree? Or a merge between three branches? Does it just show a diff between the last common point in history?
Git commits are, in fact, snapshots
... because of that, you need to specify two commits to make a diff from. E.g. git diff HEAD^ HEAD. Second reference is set to HEAD if not specified.
But yes, for example git log -p shows the patch with regard to the first parent to make things easier. And GitHub/Lab behaves just the same.
Parents are ordered
And the first parent of merge commit points to the commit you were standing on before calling git merge. (Where your HEAD was.)
By default, the first parent is always taken. For example HEAD^ is the first parent of HEAD (on the second image 6f01964), HEAD~2 is the first parent of first parent of HEAD (2bb48b5). This can be overridden by ^<number> so HEAD^2 is the second parent of HEAD, thus b0417C3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With