Merging Branches
Merging integrates changes from one branch into another. Git automatically finds the common ancestor and combines changes. There are two main strategies: fast-forward (linear) and three-way merge (creates a merge commit).
01.Fast-Forward Merge
When the target branch (main) has no new commits since the feature branch was created, Git can simply move the pointer forward — no merge commit is needed. The result is a perfectly linear history. This is the default when possible and keeps history clean and readable.
02.Three-Way Merge
When both branches have new commits since they diverged, Git performs a three-way merge using: the tip of your current branch, the tip of the incoming branch, and their common ancestor commit. Git creates a new "merge commit" with two parents. Use --no-ff to always force a merge commit even when fast-forward is possible.
Commands
When does a fast-forward merge happen?