Introduction

Git is an essential version control tool in modern software development. Effective Git usage involves systematic branch management, and following a consistent branch naming convention is a crucial part of it. In this post, we will discuss the fundamental rules and best practices for Git branch naming.

Basic Naming Conventions

Here are the basic branch naming conventions:

  1. Use lowercase: Branch names should always be in lowercase.
  2. Use hyphens (-): Separate words with hyphens.
  3. Be concise: Keep branch names concise but descriptive.
  4. Use English: Favor English for global accessibility.

Example: feature-user-authentication

Branch Prefixes

To make the purpose of a branch clear, use prefixes such as:

  1. feature/: Developing new functionality
    • Example: feature/login-system
  2. design/: Design changes
    • Example: design/landing-page-redesign
  3. bugfix/: Bug fixes
    • Example: bugfix/login-error
  4. hotfix/: Urgent production bug fixes
    • Example: hotfix/security-vulnerability
  5. release/: Preparing a new product release
    • Example: release/v1.2.0
  6. refactor/: Code refactoring
    • Example: refactor/improve-performance
  7. docs/: Documentation updates
    • Example: docs/api-guide
  8. test/: Test-related changes
    • Example: test/integration-tests
  9. chore/: Build tasks, package manager configuration, etc.
    • Example: chore/update-dependencies
  10. style/: Code style changes (formatting, linting, etc.)
  • Example: style/lint-fixes
  1. perf/: Performance improvements
    • Example: perf/optimize-database-queries

Using these prefixes helps in quickly identifying the purpose of a branch and brings structure to project management.

Issue Tracker Integration

If you use an issue tracker (e.g., JIRA, GitHub Issues), it’s advisable to incorporate the issue number into the branch name.

Example: feature/LOGIN-123-implement-oauth

Versioning

When working on a specific version, include the version number.

Example: release/2.1.0 or hotfix/2.0.1-login-issue

Temporary Work Branches

For personal experiments or temporary work, use a wip/ (Work In Progress) prefix for the branch.

Example: wip/experiment-new-algorithm

Long-Lived Branches

The project’s main long-lived branches are typically named as:

  • main or master: Main release branch
  • develop: Development branch for the next release

Conclusion

Following a consistent Git branch naming convention greatly enhances project management. Sharing and adhering to these conventions among team members can significantly improve collaboration efficiency. Feel free to customize these rules based on your project’s specifics.

Remember, a good branch name should be self-explanatory, conveying the purpose and scope of the work.