less than 1 minute read

Merge commits a just like regular commits with just more than one parent.

When browsing the history of regular commits things are very intuitive since each commit has just one parent. This way they are chained linearly and you can just hop from one to its parent until you reach your target commit (or hit the root commit which is the one with no parents).

Merge commits pose an issue as you need to decide which parent to follow in the chain, provided that you can’t traverse all the possible paths.

The answer is: follow the first parent. This is documented in the git log page although, as usual, it’s not easy to grasp.

Long story short, when merging commits, git does not store parents in a random order but the first commit is always the one in the current branch while the second (and more, in case of octopus merges) follow in the order.

Nyx always follows the first parent to make sure it follows the right chain.

You can find more on this git log --first-parent documentation or at this post.

Tags:

Categories: ,

Updated: