Draft
Respect repository default branch in gh stack link#265
gh stack link#265Conversation
Copilot
AI
changed the title
[WIP] Fix
Respect repository default branch in Jul 22, 2026
gh stack link to respect default branch of repositorygh stack link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh stack linkhardcoded--basetomain, so omitting the flag retargeted the bottom PR of the stack tomainregardless of the repository's actual default branch. It now resolves the default branch dynamically, matchinggh stack init.Changes
cmd/link.go:--basenow defaults to"". When unset,runLinkCreateOrUpdateresolves the bottom base viagit.DefaultBranch()(the same path asinit), erroring withUse --base to specify the base branchif it can't be determined. Add-mode is unaffected since it ignores--baseby design.cmd/link_test.go: Addedgit.SetOpsmocks to existing PR-number/URL create-path tests (previously leaning on real git ops), plus focused tests for retargeting an existing bottom PR to the default branch, creating a bottom PR on it, the unresolvable-default error, and explicit--basebypassing resolution.README.md,docs/reference/cli.md,skills/gh-stack/SKILL.md): updated the--basedefault description.Behavior
gh stack linkdoes not respect the default branch of a repository #260