GIT Branching — Naming Convention and Guidelines
A consistent Git branch naming convention makes it easier to understand the work being done in a particular branch when team members are working together. Additionally, it facilitates finding a specific branch within a repository.
Below, we explore some best practices for Git branch naming conventions. Hope the following will be useful to to skyrocket the efficiency.
Guidelines to follow;
- Name format: It is preferable to construct the branch name format in a sequence that includes the feature name, feature id, project code, and branch type.
- For example,feature/project-a/login
orfeature/project-a/jira-id-1932'
. - Forward Slash Separator: Use the forward slash separator to separate the branch type, project-code, and feature id, just like you would in URLs or file paths. When viewed from an IDE such as IntelliJ, this will aid in the construction of the branch tree.
- For example,feature/project-a/login
orfeature/project-a/jira-id-1932'
. - Kebab Case: One of the most readable ways to combine several words into one is the kebab case. All the words will be in lowercase, and each word will be separated by a dash aka hyphen. You should have encountered this case in the URLS mostly.
- For example,feature/transfer-customer
Note: It is acceptable to use uppercase to match the JIRA project ID in the branch name if a JIRA ID is to be used.
- For example,feature/USAID-2456
- Alpha-numeric Characters: Avoid the usage of white spaces, special characters (except for hyphens, full-stop) within the branch name, or the usage of just numbers for the branch name
- For example,purchase history
,transfer-cx's-id
,release/v2.1
or24566
- Avoid continuation of hyphens:
- For example,add--new--customer
- Avoid preceding or tailing hyphens:
- For example,-customer-delete
orcustomer-amendment-
- Descriptive, But Short, and Sweet: The feature name must be brief and accurate in addition to being informative. Steer clear of long branch names.
- For example,customer-type-premier-update-with-validation-a-and-c
- Avoid using Author names: To help you identify your branch, don’t enter your name or the initials of the name.
- For example,jira-id-1231-alex
orjoanna-payment-feature'
Conventional examples based on different use cases/branch — prefixes;
- Master Branch:
master
- Development Branch:
develop
- Release Branch:
release/project-code/[tag-version]
- Feature Branch:
feature/project-code/[feature-name]
orfeature/project-code/[feature-id]
- Hotfix Branch:
hotfix
- Fix/Bugfix Branch :
fix/defect-9833
orbugfix/login-error
- Documentation Branch:
doc/intergration-details
ordoc/api-endpoints
- Temporary Merging Branch:
merge/[merge-name]
Even though the system itself does not enforce branch naming conventions, they are essential for keeping a clear and intelligible codebase, particularly when working in a team. You can make sure that your branches are easily recognized by adhering to these conventions.