Create Issue Branch Github
Create a branch linked to a GitHub issue and check it out locally.
Create a branch linked to a GitHub issue and check it out locally.
$ARGUMENTS is the issue number. If $ARGUMENTS is empty, ask the user to provide an issue number and stop.
Steps:
- Check that
ghis installed and authenticated by runninggh auth status. If not, tell the user and stop. - Run
gh issue view $ARGUMENTS --json title,stateto confirm the issue exists. If it doesn't exist or is already closed, tell the user and stop. - Check if
gh issue developis available by runninggh issue develop --help 2>/dev/null. Then:- If available: Run
gh issue develop $ARGUMENTS --checkout. Pass--name <name>if a custom name was provided in $ARGUMENTS. GitHub names the branch<number>-<issue-title-slug>automatically and links it to the issue. - If not available (older gh): Derive the branch name from the issue number and title: lowercase the title, replace spaces and special characters with hyphens, truncate to ~5 words, and prefix with the issue number (e.g.
12-add-decision-command). Rungit checkout -b <branch-name>.
- If available: Run
- Tell the user the branch name and confirm they are now on it.
- If
gh issue developwas used: note that the branch is linked to the issue and will appear in the issue's Development sidebar automatically. - If the fallback was used: note that
gh issue developrequires gh v2.11+ and suggest upgrading. Advise addingCloses #<number>to the PR description to link the issue when opening a PR.
- If