GitHub Issue Integration
worktree can derive branch names directly from GitHub issues in the current repository, and assign the
issue to you at the same time.
Basic Usage
worktree branch --github 42
worktree branch --github "#42"
worktree branch --github 42 --assignThe generated branch name is shown as the default in the prompt, so you can accept it or edit it before creation. A non-interactive run takes it without asking.
How Branch Names Are Built
- Read issue number and title from the GitHub API.
- Sanitize the title into a branch-safe slug: lowercase letters, digits and dashes only, so a title can never add a
/or..to the name. - Cut the slug to at most 48 characters at the last dash, so it ends on a whole word. A single word longer than 48 characters is cut at 48.
- Optionally prepend a configured prefix based on issue type, giving
<prefix><number>-<slug>.
For example, an issue 42 titled “Add a dark mode toggle to the settings page so that users can switch themes at runtime” becomes 42-add-a-dark-mode-toggle-to-the-settings-page-so. The name is the same whether or not you are prompted.
Supported issue-type prefix mapping:
Feature->branchPrefix.featureBug->branchPrefix.bugfixTask->branchPrefix.chore
If a prefix key is not configured, no prefix is applied.
Authentication Resolution
Authentication is resolved in this order:
- Existing
github.tokenin local git config. gh auth tokenfrom GitHub CLI.- Interactive prompt for a token, then save to local git config. A non-interactive run has no prompt: it exits
2namingworktree config github.token <token>orgh auth login, and never prints a token.
Reading an issue and assigning one need different amounts of access. A public repository answers an
unauthenticated read, which is why --github has never required a token there. Assigning always requires
a token, and that token needs push access to the repository — so the first time you assign on such a
repository you may be asked for one, unless the resolution order above already supplies it.
Assigning the Issue
Creating the branch is the moment you have demonstrably started work, so worktree can say so on the issue
for you.
The decision is made in this order:
--assignassigns it to the authenticated user;--no-assignskips it for that run.github.autoAssign:truealways,falsenever. An explicitfalseis respected in every mode.- A non-interactive run assigns. The default is not saved, so one unattended run does not settle the key.
- Otherwise you are asked once, and your answer is saved to
github.autoAssign.
To change your mind later:
worktree config github.autoAssign trueworktree confirms the assignment against the API response rather than assuming it worked, and reports a
warning if the issue comes back without you on it. A failed assignment never stops the branch — the
worktree is created regardless.
Suggested Setup
worktree config github.token <token>
worktree config github.autoAssign true
worktree config branchPrefix.feature feature/
worktree config branchPrefix.bugfix fix/
worktree config branchPrefix.chore chore/You can also configure only missing values:
worktree config --missing --names github.token,github.autoAssign,branchPrefix.feature,branchPrefix.bugfix,branchPrefix.chore