Skip to content
Ramesh Gautam

Git branching habits that keep agency projects calm

Git branching habits that keep agency projects calm, a Workflow article by Ramesh Gautam

On agency projects several people touch the same codebase, often on deadlines. Good Git branching habits are what stop that from turning into lost work and late-night merges.

One branch per change

Every task gets its own branch from the main branch, named so anyone can tell what it is:

git switch -c feature/hero-block
git switch -c fix/mobile-menu-focus

Short-lived branches merge cleanly. Long-lived ones drift and collide.

Small, focused commits

A commit should do one thing and say what it does. "Fix footer button contrast" is useful in a year. "Updates" is not. Small commits also make it easy to revert a single change without undoing a day of work.

Review before merge

Even a quick review catches problems. My checklist when reviewing a pull request:

  • Does it do what the task asked, and nothing unrelated?
  • Is output escaped and input sanitised?
  • Does it work on mobile and with the keyboard?
  • Are there leftover debug statements or commented-out code?

Keep the repository clean

Some things never belong in Git. A theme's .gitignore usually includes:

node_modules/
vendor/
build/
.env

WordPress core, uploads and local configuration stay out of the repository too.

Automate what you can

CI/CD pipelines that lint code and deploy from the main branch remove whole categories of manual mistakes. Even a linting step on every pull request is worth setting up.