Set default base branch for new PRs
heaths opened this issue · 0 comments
Describe the feature or problem you’d like to solve
When working against a feature branch with branch protection (or rulesets) set, it would be very helpful to be able to set the default branch for subsequent gh pr create
commands.
Proposed solution
I can think of a couple options numbered according to my preference, as well as for ease of reference in comments.
- Figure out the closest branch (at least local, if not remote) and use that as the base. To avoid breaking current behavior, a new switch could be added e.g.,
--auto-base
. That is, what is a branch that contains a more recent commit that is not only in the current branch. - Set a marker in
.git/config
(with worktree support, of course) much likegh repo set-default
does. The downside is that you have to remember to unset or move this.
Additional context
Major feature work may happen in a feature branch while the repo stays on main
or something, so most contributors' PRs should be against main
and only those virtual team members working on the feature branch should use it as a base for PRs.
gh
is in a unique position to do something here because creating a pull request (outside of email/mailbox) is outside the scope of Git, and there's probably no great way for the web site to do this (well, maybe isolated storage to roam or even a local cookie).