Skip to content

Git Merge Strategies — DevOps Workflow ​

When integrating feature branches into main or releasing, merge strategy choice affects history readability, CI traceability, and rollback.

Quick comparison ​

StrategyCommand / configResultBest for
Fast-forward (FF)git merge --ff-onlyLinear history, no merge commitShort-lived feature branches, clean rebase
No fast-forwardgit merge --no-ffExplicit merge commit, preserves branch identityReleases, long-running features, audit trails
Squashgit merge --squashOne commit from branch onto targetEphemeral PR branches, clean main
Ours / Theirs (resolution)git merge -X ours / -X theirsFavor one side during conflictHotfix overrides, vendor sync

Practical CI usage ​

bash
# Enforce explicit merge commits for release branches (audit trail)
git merge --no-ff release/v2.4.0 -m "merge(release): v2.4.0 deploy gate"

# Squash a feature PR into main to keep history linear
git checkout main
git merge --squash feature/auth-refactor
git commit -m "feat(auth): refactor token flow" --no-edit

# Resolve recurring config drift quickly with ours/theirs
git merge -X ours upstream/config --no-edit

Conflict automation (DevOps) ​

bash
# Pre-set merge strategy preference globally for CI
git config --global merge.conflictstyle zdiff3
# Favor ours during vendor updates
git merge -s recursive -X ours vendor/update

Key benefit: merge strategy controls traceability. Use --no-ff for deploy/release gates (reversible), --squash for feature PRs (clean), -X ours/theirs for automated vendor/config sync.

Git Master — Git Reference for Every Skill Level