Key Facts
- Category
- Development
- Input Types
- text, checkbox, number
- Output Type
- json
- Sample Coverage
- 4
- API Ready
- Yes
Overview
The Git Branch Name Validator checks branch names against Git's official naming conventions and customizable rules, helping developers avoid errors and maintain consistent repository practices.
When to Use
- •When creating a new Git branch to ensure it meets naming standards
- •Before committing code to validate branch names in pre-commit hooks
- •In CI/CD pipelines to automatically enforce naming conventions
How It Works
- •Enter the branch name you want to validate in the input field
- •The tool applies Git's naming rules and any custom settings like allowed prefixes or maximum length
- •Receive a JSON response indicating validity and listing any specific violations
Use Cases
Examples
1. Validating a Feature Branch
Software Developer- Background
- A developer is creating a branch for a new login feature.
- Problem
- Ensure the branch name 'feature/user-login' follows Git conventions and team standards.
- How to Use
- Enter 'feature/user-login' in the branch name field and submit for validation.
- Outcome
- The tool confirms the name is valid, allowing the branch to be created without issues.
2. Enforcing Naming Conventions in CI
- Background
- A team wants to automate branch name checks in their CI/CD pipeline.
- Problem
- Prevent branches with invalid names or missing prefixes from being merged.
- How to Use
- Configure the tool with enforceConvention set to true and allowedPrefixes as 'feature/,bugfix/,hotfix/', then validate branch names in the pipeline.
- Example Config
-
enforceConvention: true, allowedPrefixes: 'feature/,bugfix/,hotfix/' - Outcome
- Invalid branch names are flagged, ensuring only compliant names proceed, maintaining repository consistency.
Try with Samples
developmentRelated Hubs
FAQ
What invalid characters does the tool check for?
It checks for characters like ~, ^, :, spaces, tabs, newlines, ?, *, [, \, and others as per Git rules.
Can I allow custom prefixes beyond the defaults?
Yes, use the allowedPrefixes option to specify prefixes such as 'feature/', 'bugfix/', or others.
What is the default maximum branch name length?
The default is 255 characters for filesystem compatibility, but you can adjust it with the maxLength option.
How do I add reserved branch names?
Use the reservedNames option to input comma-separated names like 'HEAD,main,master' that should be avoided.
What format is the validation result in?
The result is in JSON format, showing whether the name is valid and any errors found.