git-jira-branch
Quick start
Given a ticket like TICKET-1234:
# 1. Look for an existing branch
git branch --list "TICKET-1234-*"
# 2a. Branch found — switch to it
git checkout TICKET-1234-my-feature
# 2b. No branch found — delegate to the helper script
jiraSwitchToBranch TICKET-1234
Workflow
- Extract the ticket number from the user's message (e.g.
PROJ-42,ABC-1234). - Search local branches for a branch whose name starts with
<TICKET>-:git branch --list "<TICKET>-*" - If exactly one match → check it out:
git checkout <matched-branch> - If multiple matches → list them and ask the user which one to use.
- If no match → run the helper:
The script handles branch creation and checkout automatically; report its output to the user.jiraSwitchToBranch <TICKET>
Notes
- Always search local branches first (
git branch --list), not remote. - The ticket prefix match is case-sensitive; use the ticket number exactly as provided.
- Do not create branches manually —
jiraSwitchToBranchis the authoritative tool for that. jiraSwitchToBranchis not loaded in you environment, so runsh ~/.config/helpers/switchToJiraBranch.sh