All guides

Working practices

Git Standards

How we name repositories, branch, and write commit messages so that a codebase stays legible to the next person.

Updated Sep 11, 20263 min read
git
standards
branching
conventional-commits

These are the conventions used across Push projects. None of them are clever. Their value is in being applied the same way every time, so that anyone can open a repository and know where they are.

  • Use snake or kebab case and no spaces. Lowercase letters with underscores or hyphens read well and avoid URL-encoding problems.
  • Name for the permalink. A repository name should survive for the life of the content, so choose one you will not need to change.
  • Prefix with the organisation. MSFT for Microsoft, NEWCO for a new company. The prefix makes ownership obvious at a glance.
  • Domain first, then topic. Finance.Billing or Retail.Inventory says what the code is for before it says what it is.
  • Separate infrastructure and operations. Keep infrastructure and operational content in their own repositories so each one has a single purpose.
  • Support a code wiki. Knowledge management is first-class. Give technical writers somewhere to document the code alongside it.
PatternPurposeExample
<organisation>-<topic>The bulk of the assets, source and documentation for a topic or projectMSFT-Billing, NEWCO-Inventory
<organisation>-<domain>-<topic>As above, with the domain named firstMSFT-Finance-Billing, NEWCO-Retail-Inventory
<organisation>-<domain>/Documentation or /docsDocumentation and the code wikiMSFT-Finance/Documentation, NEWCO-Retail/docs
<organisation>-<domain>-OperationsMonitoring and security setupMSFT-Finance-Operations
<organisation>-<domain>-InfrastructureInfrastructure creationNEWCO-Retail-Infrastructure

Work is separated into branches by purpose and stage.1

  • main is the stable, production-ready branch. No direct commits. Production builds come only from here, after the work has been tested and reviewed elsewhere.
  • Feature branches (feat/name-of-the-feature) are created per feature. When the feature is complete it merges to main through the agreed conditions and pipelines, which normally means deploying through development, test and possibly user-acceptance environments on the way.
  • Story branches (story/name-of-task) branch from a feature branch for smaller tasks. Builds from story branches deploy to development and test. A finished story merges back into its feature branch.
  • Hotfix branches (hotfix/some-name) are rare. They branch from main when a critical production issue is found. Once the hotfix ships, every feature branch takes the update from main so the same issue is not reintroduced.

Restrict which branches can deploy to which environments. Without that rule, branch approvers receive an approval email for every build, and once the number of pending approvals grows past a threshold, automatic builds stop.

All commit messages are in English so that anyone can contribute.

We use Conventional Commits: the message reads as a sentence whose first word is the type of change, followed by a description.2

Good

code
git commit -m "feat: allow provided config object to extend configs"
git commit -m "docs: correct spelling of CHANGELOG"
git commit -m "feat(lang): add the Portuguese language"

Bad

code
git commit -m "Add placeholder on input"

Footnotes🔗

  1. Driessen, V. (2010). A successful Git branching model. nvie.com ↩

  2. Conventional Commits 1.0.0. conventionalcommits.org ↩

Git Standards | Push Manifesto · Push Manifesto