Git Branching Strategies, Merge Workflows, and Conflict Resolution
Selecting the right branching model determines delivery speed and release reliability. This guide compares Trunk-Based Development vs. GitFlow, details merge mechanics (Fast-Forward, 3-Way Merge, and Squash & Merge), and outlines systematic merge conflict resolution.
⚡ Quick Dive
Merge Strategies Rosetta Stone
| Strategy | Command | Commit History Shape | Best For |
|---|---|---|---|
Fast-Forward (--ff) |
git merge feature (no main changes) |
Linear line (Pointer moves forward) | Simple single-developer branches |
No Fast-Forward (--no-ff) |
git merge --no-ff feature |
Preserves explicit branch topology | Release branches in GitFlow |
| Rebase & Merge | git rebase main && git merge --ff-only |
100% Clean Linear History | High-velocity Trunk-Based teams |
| Squash & Merge | git merge --squash feature |
Combines 20 micro-commits into 1 clean commit | Pull Request mergers on GitHub/GitLab |
📖 Extended Guide
1. Trunk-Based Development vs. GitFlow
Trunk-Based Development:
main: ──●──●──●──●──●──●──●──► (Short-lived feature branches merged daily via Feature Flags)
└──●──┘ (PR < 24h)
GitFlow:
main: ──●───────────────────────●──────────► (Production only)
develop: ──●──────●──────●─────────●──────────► (Integration branch)
└──feature───┘ └──release──┘
2. Systematic Merge Conflict Resolution
# 1. Use 3-way diff tool (Diff3 displays common ancestor)
git config --global merge.conflictstyle diff3
# 2. Inspect conflicting files
git status
# 3. Abort merge safely if needed
git merge --abort