Git Branch Naming Conventions and Best Practices

Learn common git branch naming conventions: feature/, bugfix/, hotfix/, release/. Understand how naming affects CI/CD pipelines, code review, and team workflows.

Branching

Detailed Explanation

Git Branch Naming Conventions

Consistent branch naming improves team communication, enables CI/CD automation, and makes repository navigation easier.

Common Prefixes

Prefix Purpose Example
feature/ New features feature/user-auth
bugfix/ Non-urgent bug fixes bugfix/login-redirect
hotfix/ Urgent production fixes hotfix/payment-crash
release/ Release preparation release/v2.1.0
chore/ Maintenance tasks chore/update-deps
docs/ Documentation updates docs/api-reference
experiment/ Experimental work experiment/new-algorithm

Naming Rules

  1. Use lowercase with hyphens: feature/user-auth (not Feature/UserAuth)
  2. Include a ticket number if your team uses issue trackers: feature/JIRA-123-user-auth
  3. Keep it short but descriptive: bugfix/null-pointer not bugfix/fix-the-null-pointer-exception-in-user-service
  4. No spaces -- use hyphens: feature/add-search
  5. No special characters except / and -

CI/CD Integration

Branch names can trigger different CI/CD behaviors:

# GitHub Actions example
on:
  push:
    branches:
      - main          # Production deploy
      - release/*     # Staging deploy
      - feature/*     # Run tests only

Gitflow Naming

The Gitflow model uses specific branch names:

  • main -- production-ready code
  • develop -- integration branch
  • feature/* -- new features
  • release/* -- release preparation
  • hotfix/* -- urgent production fixes

Trunk-Based Development

Simpler naming with short-lived branches:

  • main -- the only long-lived branch
  • <developer>/<short-description> -- e.g., jane/add-login

Cleanup

# Delete merged local branches
git branch --merged main | grep -v main | xargs git branch -d

# Delete merged remote branches
git remote prune origin

Use Case

Branch naming conventions are one of the first decisions a team makes when establishing their git workflow. Consistent naming enables automated deployments (branches matching certain patterns trigger specific pipelines), simplifies code review (reviewers can identify the purpose of a branch at a glance), and improves repository organization. Many teams enforce naming conventions through pre-push hooks or branch protection rules.

Try It — Git Command Reference & Cheat Sheet

Open full tool