When you use the
git merge command to merge a branch/commit into your current branch, it joins their development histories together in a new commit. This new commit records both as its parents; the branch/commit you're merging in and the branch you are on when the merge occurs. The parent that gets recorded first (in the commit object of the new commit) is considered the "first parent", while the other one is considered the "second parent".
It is possible for a commit to have an arbitrary number of parents. This can happen, for example, when you
git merge more than one branch/commit into your current branch. In such case, the hash of each parent is stored in the commit object, for example, like so:
# ... parent 81c948a6488fc505be7eb22575a15e2db65c5d32 parent bdb425d2e0f76f30991f9c92c33fdfb9b09918ff # ...
Typically, (in all popular git platforms) the parent that gets recorded first is the branch you were on when you merged. However, this behavior depends on the merge workflow specified in the repository, and can be different.
You can use the
git show --first-parent or
git log --first-parent command to follow the first parents only.
Hope you found this post useful. It was published (and was last revised ). Please show your love and support by sharing this post.