Git Branch Names from GitHub Issue Numbers
Create branch names from GitHub issue numbers (#123). Link your branches to issues automatically for streamlined pull request workflows.
Detailed Explanation
GitHub Issue Branch Names
GitHub issues are referenced by a simple number prefixed with # (e.g., #123, #4567). Including the issue number in your branch name enables GitHub's automatic issue-to-PR linking and helps maintain a clean audit trail.
Standard Format
{type}/{issue-number}-{description}
Examples
| Issue | Title | Branch Name |
|---|---|---|
| #123 | Add dark mode support | feature/123-add-dark-mode-support |
| #456 | Fix broken search | bugfix/456-fix-broken-search |
| #789 | Update dependencies | chore/789-update-dependencies |
| #1011 | Add API rate limiting | feature/1011-add-api-rate-limiting |
GitHub Automatic Linking
When you create a pull request from a branch that contains an issue number, GitHub provides several automatic behaviors:
- Issue reference in PR — The PR sidebar shows the linked issue
- Auto-close on merge — Adding "Closes #123" or "Fixes #123" in the PR description (or commit message) automatically closes the issue when the PR merges
- Development section — The issue page shows the linked branch and PR in the Development sidebar
GitHub CLI Integration
You can combine the generated branch name with the GitHub CLI for a seamless workflow:
# Create branch and set up tracking
git checkout -b feature/123-add-dark-mode-support
# Create PR that references the issue
gh pr create --title "Add dark mode support" --body "Closes #123"
Naming Tips for GitHub Workflows
- Strip the # prefix — Git branch names cannot contain
#(it's treated as a comment character in some contexts). The tool automatically removes it, keeping just the number. - Number positioning — Place the issue number immediately after the type prefix for consistency:
feature/123-descriptionrather thanfeature/description-123. - Organization repos — For repos with many contributors, consider adding your username:
feature/username/123-description.
Use Case
An open-source maintainer wants contributors to follow a consistent branch naming pattern that links back to GitHub issues, making it easy to track which branches address which issues in the project board.