Checkout branch for issue
Describe the feature or problem you’d like to solve
Right now, we can checkout branches related to PRs, but it doesn't look like that same functionality exists for issues (since GitHub web now allows you to automatically create branches associated with issues, before creating a PR).
Proposed solution
It would be nice if there were a new gh issue checkout {<number> | <url>} command. When called:
- If a branch has already been created for that issue,
- It checks out the branch.
- If a branch has not already been created for that issue,
- It calls GitHub API to create the branch automatically (does the API support this yet?)
- It checks out the new branch.
It's beneficial because it allows developers to get started on new issues quickly using the CLI, rather than having to open the web interface and create the branch there first.
I would think this command should support the same options the gh pr checkout command has:
-
--branchfor the local branch name. -
--detachfor detached HEAD -
--forceto reset to the remote branch. -
--recurse-submodules
Additional context
Arguably, it's not that hard to workaround this. If the branch already exists, you can git fetch and tab-complete the issue number (as long as you're sticking with the default naming scheme). If the branch doesn't exist, you could create your own branch, but then the new branch you've created isn't connected with the issue (until you submit a PR?).
@sammarks Thanks for the feature request. This is something that we want to implement in the future, we are still unsure of how we want to design it though, so we appreciate your proposal.
cc https://github.com/github/special-projects/issues/1219
Describe the feature or problem you’d like to solve
Right now, we can checkout branches related to PRs, but it doesn't look like that same functionality exists for issues (since GitHub web now allows you to automatically create branches associated with issues, before creating a PR).
Proposed solution
It would be nice if there were a new
gh issue checkout {<number> | <url>}command. When called:
If a branch has already been created for that issue,
- It checks out the branch.
If a branch has not already been created for that issue,
- It calls GitHub API to create the branch automatically (does the API support this yet?)
- It checks out the new branch.
It's beneficial because it allows developers to get started on new issues quickly using the CLI, rather than having to open the web interface and create the branch there first.
I would think this command should support the same options the
gh pr checkoutcommand has:
--branchfor the local branch name.--detachfor detached HEAD--forceto reset to the remote branch.--recurse-submodulesAdditional context
Arguably, it's not that hard to workaround this. If the branch already exists, you can
git fetchand tab-complete the issue number (as long as you're sticking with the default naming scheme). If the branch doesn't exist, you could create your own branch, but then the new branch you've created isn't connected with the issue (until you submit a PR?).
Describe the feature or problem you’d like to solve
Right now, we can checkout branches related to PRs, but it doesn't look like that same functionality exists for issues (since GitHub web now allows you to automatically create branches associated with issues, before creating a PR).
Proposed solution
It would be nice if there were a new
gh issue checkout {<number> | <url>}command. When called:
If a branch has already been created for that issue,
- It checks out the branch.
If a branch has not already been created for that issue,
- It calls GitHub API to create the branch automatically (does the API support this yet?)
- It checks out the new branch.
It's beneficial because it allows developers to get started on new issues quickly using the CLI, rather than having to open the web interface and create the branch there first.
I would think this command should support the same options the
gh pr checkoutcommand has:
--branchfor the local branch name.--detachfor detached HEAD--forceto reset to the remote branch.--recurse-submodulesAdditional context
Arguably, it's not that hard to workaround this. If the branch already exists, you can
git fetchand tab-complete the issue number (as long as you're sticking with the default naming scheme). If the branch doesn't exist, you could create your own branch, but then the new branch you've created isn't connected with the issue (until you submit a PR?).
I think it would be quite practical if gh also gave us the option to create a branch after creating an issue in the "What's next?" dialog we're prompted with. My current workflow is creating the issue from cli, then select continue in browser, submitting issue, then pressing create branch. It would be quite smooth if I could complete the issue as normal from the cli, then selecting "create branch", which would create a branch in origin, fetch and checkout locally.
This got shipped as gh issue develop https://github.com/cli/cli/pull/6254