Branch Name Length Limits and Truncation

Understand git branch name length limits and how to truncate long branch names at word boundaries while preserving readability and ticket references.

Best Practices

Detailed Explanation

Branch Name Length and Truncation

While git itself supports branch names up to 255 characters (limited by the filesystem), practical considerations and team conventions typically set much shorter limits. Understanding these limits and how to truncate intelligently helps maintain clean, usable branch names.

Common Length Limits

Context Limit Reason
Git filesystem 255 chars OS path length restrictions
GitHub UI ~100 chars Truncated in branch selector dropdown
Terminal display ~60-80 chars Fits in standard terminal width
CI/CD systems Varies Some artifact naming uses branch names
Docker tags 128 chars Image tags derived from branches

Recommended Limit: 60-80 Characters

A branch name of 60-80 characters fits comfortably in:

  • Terminal prompts (with room for the git status)
  • GitHub's branch selector dropdown
  • CI/CD dashboard columns
  • Slack/Teams notifications

Smart Truncation Strategy

The Git Branch Name Generator truncates at word boundaries to avoid broken words:

Before Truncation (92 chars) After Truncation (78 chars)
feature/proj-1234-implement-user-authentication-with-oauth2-and-social-login-providers feature/proj-1234-implement-user-authentication-with-oauth2-and-social-login

Truncation Rules

  1. Preserve the type prefix — Never truncate the feature/, bugfix/, etc. prefix
  2. Preserve the ticket number — The ticket reference must remain intact for traceability
  3. Cut at word boundary — Find the last separator (hyphen, underscore, or slash) before the max length and cut there
  4. Remove trailing separators — Clean up any dangling hyphens or underscores after truncation

Tips for Avoiding Truncation

  • Use abbreviations for common words: auth instead of authentication, impl instead of implement
  • Focus on the core change: add-oauth-login instead of add-oauth2-authentication-with-google-and-github-social-login
  • Let the ticket description provide full context; the branch name is a quick identifier, not a specification

Use Case

A developer creates a branch from a detailed JIRA ticket title that produces a 120-character branch name. They need to understand how truncation works and how to configure the maximum length to meet their team's 80-character convention.

Try It — Git Branch Name Generator

Open full tool