Ask five developers how to use Git branches and you’ll get six answers. GitFlow, GitHub Flow, trunk-based development, release branches, develop branches. For a team of three to ten developers, most of that complexity isn’t needed, and it slows everyone down.
Here’s a simple workflow that works well for small teams building web apps, APIs and internal systems. It keeps the main branch always deployable, makes code review routine, and avoids merge-conflict nightmares.
The workflow in one picture
main ──●────────●────────●───────●── (always deployable, tagged releases)
\ / \ / \
feature/ ●──●─● ●──●─● ●──● (short-lived, 1–3 days)
That’s it. One long-lived branch (main) and short-lived branches for every change.
The rules
mainis always deployable. Anything merged intomainmust build, pass tests and be ready to release.- Every change gets its own branch, created from the latest
main. - Branches are short-lived: ideally merged within one to three days.
- Changes reach
mainonly through a pull request (PR) with at least one review. - Automated checks must pass before merging.
- Releases are tagged on
main.
Step by step
1. Start from an up-to-date main
git switch main
git pull
2. Create a branch
git switch -c feature/invoice-pdf-download
3. Work and commit in small steps
git add .
git commit -m "Add PDF download button to invoice page"
Commit whenever you reach a sensible checkpoint. Small commits are easier to review and easier to undo.
4. Push and open a pull request
git push -u origin feature/invoice-pdf-download
Open a pull request on GitHub, GitLab, Azure DevOps or Bitbucket. Describe what changed and why, how to test it, and include screenshots for UI changes. Link the issue or task.
Open the PR early (as a draft) if you want feedback before it’s finished.
5. Keep your branch current
If main has moved on while you were working, bring those changes in:
git fetch origin
git rebase origin/main # or: git merge origin/main
Rebase gives a cleaner history but rewrites your branch’s commits, so after rebasing a pushed branch you’ll need git push --force-with-lease. Merge is safer if others are working on the same branch. Pick one approach as a team and stick to it.
6. Review, then merge
After approval and passing checks, merge the PR. Many small teams use squash merge, which turns all the branch’s commits into one tidy commit on main with the PR title as its message.
7. Delete the branch
Most platforms can do this automatically after merging. Old branches just add clutter.
Branch naming
Simple, consistent prefixes help everyone see what a branch is for:
| Prefix | Purpose | Example |
|---|---|---|
feature/ | New functionality | feature/gst-report-export |
fix/ | Bug fixes | fix/login-redirect-loop |
hotfix/ | Urgent production fix | hotfix/payment-callback-timeout |
chore/ | Maintenance, upgrades, config | chore/upgrade-dotnet-10 |
docs/ | Documentation only | docs/api-auth-guide |
Including a ticket number helps traceability: feature/482-gst-report-export.
Commit messages that help later
A good commit message explains the change to someone reading the history six months from now:
Fix duplicate invoice numbers under concurrent requests
Two requests could read the same last invoice number before either saved.
Use a database sequence instead of reading MAX(InvoiceNo) + 1.
- Short summary line (about 50–72 characters), in the imperative: “Fix”, “Add”, “Remove”.
- A blank line, then details if needed: why you made the change, not just what.
Some teams use Conventional Commits (feat:, fix:, chore:), which can generate changelogs automatically. Useful, but optional.
Protect the main branch
In your repository settings, add a protection rule for main:
- require a pull request before merging
- require at least one approval
- require status checks (build and tests) to pass
- block force pushes and deletion
- optionally, require branches to be up to date before merging
This turns your rules from good intentions into guarantees.
Releases and hotfixes
Releasing
When you deploy, tag the commit on main:
git switch main
git pull
git tag -a v1.8.0 -m "Release 1.8.0"
git push origin v1.8.0
Tags let you see exactly what’s in production and redeploy a previous version if needed. Your CI/CD pipeline can deploy automatically when a tag is pushed.
Hotfixes
Production is broken and needs a fix now:
git switch main
git pull
git switch -c hotfix/payment-callback-timeout
# fix, commit, push, PR with fast review
Merge the PR, tag a patch release (v1.8.1) and deploy. Because main is always deployable and close to production, hotfixes don’t require complicated branch juggling.
Handling unfinished features
What if a feature takes three weeks? Don’t keep a branch open for three weeks; it will drift far from main and become painful to merge.
Instead:
- Break the work into smaller pieces that can each be merged safely.
- Use feature flags to merge code that isn’t ready for users yet, hidden behind a configuration switch.
- Build the back end first, without exposing it, then add the UI later.
Merging small pieces often is the single biggest way to avoid merge conflicts.
When you might need more
This workflow suits most small teams. Consider adding structure if:
- You support several released versions at once (for example, on-premises software at different clients). Add
release/x.ybranches for maintaining older versions. - You have a formal QA cycle before each release. A short-lived release branch can stabilise a version while new work continues on
main. - Mobile apps with app store review delays sometimes benefit from release branches too.
Full GitFlow, with permanent develop and release branches, was designed for scheduled, versioned releases. For continuously deployed web apps, it usually adds overhead without much benefit.
Everyday commands cheat sheet
git status # what's changed?
git switch -c feature/x # new branch
git add -p # stage changes interactively, hunk by hunk
git commit -m "Message" # commit
git push -u origin feature/x # first push of a branch
git fetch origin # get latest remote info
git rebase origin/main # update branch with main
git log --oneline --graph -15 # recent history as a graph
git stash / git stash pop # set work aside temporarily
git restore file.cs # discard local changes to a file
git revert <commit> # undo a commit safely with a new commit
Common mistakes to avoid
- Committing directly to
main. Branch protection prevents this. - Long-lived branches that turn every merge into a battle.
- Giant pull requests. Reviewers skim them, and bugs slip through. Aim for changes that can be reviewed in 15–30 minutes.
- Committing secrets. Add
.env,appsettings.Development.jsonwith secrets, and key files to.gitignore, and use secret scanning. - Force-pushing shared branches. Use
--force-with-lease, and only on your own branches.
Keep it simple
For small teams, the best Git workflow is the simplest one everyone follows: an always-deployable main, short-lived branches for every change, pull requests with review and automated checks, and tags for every release.
Add complexity only when a real need appears, not because a diagram on the internet looked impressive.
Leave a Comment