githubEdit

Naming Branches

When contributing to existing projects, look for and stick with the agreed branch naming convention. In open source projects this information is typically found in the contributing instructions, often in a file named CONTRIBUTING.md.

In the beginning of a new project the team agrees on the project conventions including the branch naming strategy.

Common Branch Naming Patterns

1. Feature-based Convention

<type>/<issue-number>-<short-description>

Examples:

feature/271-add-more-cowbell
bugfix/389-fix-memory-leak
hotfix/422-critical-auth-issue
docs/129-update-readme
test/233-improve-test-coverage
refactor/156-optimize-queries
chore/111-update-dependencies

2. Owner-based Convention

<owner>/<type>/<issue-number>-<short-description>

Examples:

3. Release-based Convention

For teams working with release branches:

4. Environment-based Convention

For GitOps workflows:

Multi-Cloud Development Considerations

When working across multiple cloud providers, you might want to include cloud provider information in branch names:

Examples:

Automation and Integration

CI/CD Pipeline Integration

Well-structured branch names can trigger specific CI/CD workflows:

Automatic Work Item Linking

Branch names with issue numbers enable automatic linking in tools like Azure DevOps:

Branch Naming Best Practices

  1. Keep it simple - Names should be intuitive and easy to remember

  2. Be consistent - Once a convention is chosen, stick to it

  3. Use lowercase - Avoid case sensitivity issues across systems

  4. Use hyphens for word separation (not underscores or spaces)

  5. Keep it short - Long branch names become unwieldy

  6. Include relevant information only - Exclude redundant details

Different Conventions for Different Development Models

Trunk-Based Development

In trunk-based development, branches are short-lived and merged frequently:

or for one-day branches:

GitFlow

For GitFlow, branches follow a more structured naming convention:

GitHub Flow

With GitHub Flow's simplified approach:

Real-World Examples

Enterprise SaaS Project

Infrastructure as Code Project

Microservices Project

Automated Branch Name Enforcement

Consider enforcing branch naming conventions through hooks or CI checks:

The examples above are just that - examples. The team can choose to omit or add parts. Choosing a branch convention can depend on the development model (e.g. trunk-based developmentarrow-up-right), versioningarrow-up-right model, tools used in managing source control, matter of taste etc. Focus on simplicity and reducing ambiguity; a good branch naming strategy allows the team to understand the purpose and ownership of each branch in the repository.

Last updated