Mastering Git Branching Models for a Smooth Development Workflow
A branching model is a set of conventions for how branches get created, named, used, and deleted in a repository. The right model keeps development organized without getting in the way. The wrong one creates merge hell.
Git branching strategies
The most referenced model is Git Flow, with five branch types: master, develop, feature, release, and hotfix. For most teams that’s more ceremony than needed. A simpler three-branch setup works well:
- Development — where features are built. Each feature gets its own branch off
development, merged back when done and tested locally. - Staging — integration and QA. When a batch of features is ready for more rigorous testing,
developmentmerges intostaging, which mirrors production. - Master — production. Only code that’s passed staging testing gets here.
Branch protections
To keep the mainline branches clean, set up branch protection rules on staging and master:
- Require pull request reviews before merging
- Require status checks to pass (tests, linting)
- Prevent force pushes
This ensures nothing goes to production without review and green CI. It also creates a useful paper trail — every change to master has an associated PR with context on why it was made.
Tags and releases
Git tags mark specific commits as meaningful — typically version releases. When code is ready for production (merged into master), create a tag:
git tag -a v1.2.0 -m "Add user authentication"
git push origin v1.2.0
Tags make rollbacks straightforward. If something breaks in production, you can identify exactly which commit introduced it and revert to the previous tag.
A typical feature flow
- Create
feature/user-authoffdevelopment - Build, test locally, push
- Open PR →
development, get review, merge - When enough features are ready, merge
development→staging - Deploy staging, run QA
- Merge
staging→master, tag the release - For hotfixes: branch directly off
master, fix, merge back to bothmasteranddevelopment
The exact workflow varies by team size and release cadence, but the principle is consistent: isolate development work, protect the branches that matter, and tag what ships.
The views and opinions expressed here are my own and do not reflect those of my employer.