Git Merge Strategy

This git merge strategy gives teams a controlled path to move code from development to production without promoting unfinished work.

It is designed for environments that use dev, stage, and master (production) branches, with explicit promotion and sync steps.

Why this git merge strategy works

  • Separates early integration testing from release-ready validation.
  • Ensures production receives only tested code from stage.
  • Reduces branch drift by syncing stage back into dev after releases.

1) Develop a feature from stage

Create each feature branch from stage so feature work starts from a stable baseline.

git checkout stage
git checkout -b feature/new-feature

2) Merge feature into dev for early testing

When implementation is ready, merge into dev for integration testing and frontend/API validation.

git checkout dev
git merge feature/new-feature

3) Promote to stage for final QA

After dev validation, merge the feature back to stage for final QA/UAT before release.

git checkout stage
git merge feature/new-feature

4) Release stage to production

Once stage passes checks, promote to production by merging stage into master.

git checkout master
git merge stage

5) Sync stage back into dev

This final sync step keeps long-running branches aligned and prevents future merge surprises.

git checkout dev
git merge stage

Hotfix flow for urgent production issues

For critical bugs, branch from production, patch quickly, and then propagate the fix across stage and dev.

git checkout master
git checkout -b hotfix/fix-urgent-bug
# Apply the fix
git checkout master
git merge hotfix/fix-urgent-bug
git checkout stage
git merge master
git checkout dev
git merge stage

Quick workflow summary

  • Feature branch: stage -> feature/*
  • Early test: feature/* -> dev
  • Release candidate: feature/* -> stage
  • Production release: stage -> master
  • Post-release sync: stage -> dev

Using this git merge strategy consistently helps teams release stable code faster and keep dev, stage, and production branches in sync.