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:
- Use lowercase: Branch names should always be in lowercase.
- Use hyphens (-): Separate words with hyphens.
- Be concise: Keep branch names concise but descriptive.
- 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:
- feature/: Developing new functionality
- Example:
feature/login-system
- Example:
- design/: Design changes
- Example:
design/landing-page-redesign
- Example:
- bugfix/: Bug fixes
- Example:
bugfix/login-error
- Example:
- hotfix/: Urgent production bug fixes
- Example:
hotfix/security-vulnerability
- Example:
- release/: Preparing a new product release
- Example:
release/v1.2.0
- Example:
- refactor/: Code refactoring
- Example:
refactor/improve-performance
- Example:
- docs/: Documentation updates
- Example:
docs/api-guide
- Example:
- test/: Test-related changes
- Example:
test/integration-tests
- Example:
- chore/: Build tasks, package manager configuration, etc.
- Example:
chore/update-dependencies
- Example:
- style/: Code style changes (formatting, linting, etc.)
- Example:
style/lint-fixes
- perf/: Performance improvements
- Example:
perf/optimize-database-queries
- Example:
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
ormaster
: Main release branchdevelop
: 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.