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.
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
- Use lowercase with hyphens:
feature/user-auth(notFeature/UserAuth) - Include a ticket number if your team uses issue trackers:
feature/JIRA-123-user-auth - Keep it short but descriptive:
bugfix/null-pointernotbugfix/fix-the-null-pointer-exception-in-user-service - No spaces -- use hyphens:
feature/add-search - 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 codedevelop-- integration branchfeature/*-- new featuresrelease/*-- release preparationhotfix/*-- 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.