Rabi Siddique
200 words
1 minutes
Types of Merges
2024-08-05

The 3-Way Merge#

Merging is the act of integrating changes from one branch into another. The most common scenario involves the 3-way merge. Imagine you’re working on a feature in a separate branch while your coworker makes updates to the main branch.

Image Credit: atlassian

Once your feature is complete, you’d merge it back into the mainline. This process results in a merge commit that combines the changes from both branches, considering their common ancestor to resolve any conflicts.

Image Credit: atlassian

It’s a straightforward way to integrate work but can lead to a complex history over time if not managed well.

Fast-Forward Merge#

In scenarios where the feature branch was created after the latest commit on the main branch and no new changes have been added to the main branch, a fast-forward merge is possible. This type of merge avoids creating a new merge commit. Instead, the HEAD pointer is moved to the tip of the feature branch, effectively absorbing it into the main branch. This results in a cleaner, linear history.

Image Credit: atlassian

A fast-forward merge is not possible if the branches have diverged. A fast-forward merge can occur when there is a linear path from the current branch tip to the target branch.

Further Reading#

Types of Merges
https://rabisiddique.com/posts/types-of-merges/
Author
Rabi Siddique
Published at
2024-08-05