From 7448aed8ab3427d522e72416989e2e025c58ce8e Mon Sep 17 00:00:00 2001 From: William Martin Date: Thu, 12 Feb 2026 16:56:14 +0100 Subject: [PATCH 1/2] fork default branch only in pr create --- pkg/cmd/pr/create/create.go | 2 +- pkg/cmd/pr/create/create_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/pr/create/create.go b/pkg/cmd/pr/create/create.go index 5b5d45f9c0a..8411cdada75 100644 --- a/pkg/cmd/pr/create/create.go +++ b/pkg/cmd/pr/create/create.go @@ -1128,7 +1128,7 @@ func handlePush(opts CreateOptions, ctx CreateContext) error { forkableRefs, requiresFork := refs.(forkableRefs) if requiresFork { opts.IO.StartProgressIndicator() - forkedRepo, err := api.ForkRepo(ctx.Client, forkableRefs.BaseRepo(), "", "", false) + forkedRepo, err := api.ForkRepo(ctx.Client, forkableRefs.BaseRepo(), "", "", true) opts.IO.StopProgressIndicator() if err != nil { return fmt.Errorf("error forking repo: %w", err) diff --git a/pkg/cmd/pr/create/create_test.go b/pkg/cmd/pr/create/create_test.go index 5ccffd7a8a8..67286902538 100644 --- a/pkg/cmd/pr/create/create_test.go +++ b/pkg/cmd/pr/create/create_test.go @@ -894,11 +894,13 @@ func Test_createRun(t *testing.T) { httpmock.StringResponse(`{"data": {"viewer": {"login": "monalisa"} } }`)) reg.Register( httpmock.REST("POST", "repos/OWNER/REPO/forks"), - httpmock.StatusStringResponse(201, ` + httpmock.RESTPayload(201, ` { "node_id": "NODEID", "name": "REPO", "owner": {"login": "monalisa"} - }`)) + }`, func(payload map[string]interface{}) { + assert.Equal(t, true, payload["default_branch_only"]) + })) reg.Register( httpmock.GraphQL(`mutation PullRequestCreate\b`), httpmock.GraphQLMutation(` From 2b5c3b5ecb8f9c6673c6996aeedc9420706ce92d Mon Sep 17 00:00:00 2001 From: William Martin Date: Fri, 13 Feb 2026 15:36:37 +0100 Subject: [PATCH 2/2] document fork default branch behavior --- pkg/cmd/pr/create/create.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/pr/create/create.go b/pkg/cmd/pr/create/create.go index 8411cdada75..3949ecbb618 100644 --- a/pkg/cmd/pr/create/create.go +++ b/pkg/cmd/pr/create/create.go @@ -214,7 +214,8 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co Upon success, the URL of the created pull request will be printed. When the current branch isn't fully pushed to a git remote, a prompt will ask where - to push the branch and offer an option to fork the base repository. Use %[1]s--head%[1]s to + to push the branch and offer an option to fork the base repository. Any fork created this + way will only have the default branch of the upstream repository. Use %[1]s--head%[1]s to explicitly skip any forking or pushing behavior. %[1]s--head%[1]s supports %[1]s:%[1]s syntax to select a head repo owned by %[1]s%[1]s.