Categories

Git Branch Name Validator

Validate Git branch names according to Git naming conventions

Git Branch Name Validator

This tool validates Git branch names according to Git's naming conventions and best practices.

Git Branch Naming Rules:

  • Cannot contain: ~ ^ : space tab newline ? * [ \
  • Cannot begin or end with /
  • Cannot have consecutive slashes //
  • Cannot end with .lock
  • Cannot contain .. or @{
  • Maximum length (typically 255 chars for filesystem compatibility)
  • Cannot be a reserved branch name (HEAD, main, master)

Common Branch Naming Conventions:

  • feature/ - New features
  • bugfix/ - Bug fixes
  • hotfix/ - Urgent production fixes
  • release/ - Release preparation
  • develop/ - Development branch
  • test/ - Testing branches
  • docs/ - Documentation updates
  • refactor/ - Code refactoring

Example Valid Names:

  • feature/user-authentication
  • bugfix/login-error
  • hotfix/security-patch-001
  • release/v1.2.3

Example Invalid Names:

  • feature user auth (contains spaces)
  • feature//double-slash (consecutive slashes)
  • .lock-branch (starts with dot)
  • feature/.lock (ends with .lock)

Use Cases:

  • Validate branch names before creation
  • Enforce team naming conventions
  • Pre-commit hooks for branch naming
  • CI/CD pipeline validation
  • Code review automation

Allow branch names without standard prefixes

Require branch names to follow naming conventions

Branch names that are reserved (comma-separated)

Maximum length for branch names (filesystem compatibility)

Valid branch name prefixes (comma-separated, end with /)

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

Automating branch name validation in development workflows
Integrating with Git hooks to prevent invalid commits
Standardizing branch names across teams and projects

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

development

Related 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.

API Documentation

Request Endpoint

POST /en/api/tools/git-branch-validator

Request Parameters

Parameter Name Type Required Description
branchName text Yes -
allowCustomPrefixes checkbox No Allow branch names without standard prefixes
enforceConvention checkbox No Require branch names to follow naming conventions
reservedNames text No Branch names that are reserved (comma-separated)
maxLength number No Maximum length for branch names (filesystem compatibility)
allowedPrefixes text No Valid branch name prefixes (comma-separated, end with /)

Response Format

{
  "key": {...},
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}
JSON Data: JSON Data

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-git-branch-validator": {
      "name": "git-branch-validator",
      "description": "Validate Git branch names according to Git naming conventions",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=git-branch-validator",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]