Fast-Forward vs 3-Way Merges
Understand how Git combines histories: sliding a pointer forward vs forging a new merge commit.
Two ways to merge
A **Fast-Forward Merge** occurs when the current branch's tip is a direct ancestor of the merging branch. Git simply moves (fast-forwards) the current branch pointer forward to the merging branch's tip without creating a new merge commit.
A **3-Way Merge** occurs when the commit history has diverged. Git uses three commits (the two branch tips and their common ancestor) to create a new, distinct 'merge commit' that integrates the divergent histories together.
Why it matters
Fast-Forward merges keep the Git history perfectly linear. This makes it easier to read the log sequentially and find regressions using tools like git bisect.
3-Way Merges preserve the context of a feature. It clearly groups related commits together and provides a dedicated merge commit that answers 'when and where was this feature introduced?'.
How it works
In a linear history, no new commits were added to the base branch while the feature branch was developed. Git just slides the pointer up the line.
In a divergent history, commits were added to both the base branch and the feature branch since they split. Git must compare both tips against their common base to resolve changes safely.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- A fast-forward merge simply moves the branch pointer forward.
- A 3-way merge creates a brand new merge commit.
- Use
--no-ffto force a merge commit and preserve the feature's context.
Done with this concept?
Mark it complete to track your progress. No login needed.