support multiple branches during init#91
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Revamps gh stack init to better support first-time onboarding and multi-branch initialization by implicitly adopting existing branches, detecting prefixes from branch names, simplifying the interactive flow, and improving post-init guidance.
Changes:
- Makes branch adoption implicit when branches already exist; creates missing branches with two-pass validation for arg parsing.
- Adds automatic prefix detection (from branch names) and updates interactive prompts accordingly; deprecates and hides
--adopt. - Reworks post-init output into a scenario-aware “What’s next” block and updates docs/examples across guides and references.
Show a summary per file
| File | Description |
|---|---|
| skills/gh-stack/SKILL.md | Updates init examples to remove --adopt and document multi-branch init/adoption. |
| README.md | Refreshes gh stack init docs to describe implicit adoption and prefix detection. |
| internal/git/mock_ops.go | Re-indents MockOps fields (formatting/consistency). |
| docs/src/content/docs/reference/cli.md | Updates CLI reference text/examples to remove --adopt and reflect new behavior. |
| docs/src/content/docs/guides/workflows.md | Adds a new section explaining how to turn existing branches into a stack via init. |
| docs/src/content/docs/faq.md | Updates FAQ examples to remove --adopt and reflect the new workflow. |
| cmd/init.go | Implements new init flow: implicit adopt/create, prefix detection, deprecated --adopt, PR detection, and new output block. |
| cmd/init_test.go | Updates/expands tests for new init behaviors (implicit adopt, prefix detection, “what’s next” output). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
cmd/init.go:483
- printWhatsNext prints
Adopted %d branchesusing len(branches) whenever hasAdopted is true, even for mixed cases where some branches were newly created. This can mislead users about what actually happened. Consider adjusting the message to distinguish adopted vs created counts (or use more neutral wording like “Initialized stack” with a breakdown).
// Success line
if hasAdopted {
cfg.Successf("Adopted %d %s: %s",
len(branches), plural(len(branches), "branch", "branches"), chain)
} else {
cfg.Successf("Created stack: %s", chain)
}
- Files reviewed: 7/8 changed files
- Comments generated: 2
c85384a to
6692218
Compare
2c85e59 to
35b0889
Compare
6692218 to
3854aa2
Compare
d1f6674 to
6f6a077
Compare
ktravers
approved these changes
May 15, 2026
6f6a077 to
0706796
Compare
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.
Revamp
gh stack initonboarding experienceRedesign the init flow to be more intuitive for first-time users: implicit branch adoption, automatic prefix detection, a simplified interactive flow, and scenario-aware post-init output.
Changes
cmd/init.go): Existing branches are now adopted automatically when passed as args — no flag needed. Missing branches are created. Two-pass validation ensures no branches are created if a later arg fails.feat/a feat/b→ prefixfeat). Interactive path confirms with Y/n; args path sets it silently.add/view/submittips; adopted stacks showview/up/down/submittips with PR count.--adopt: Flag is hidden but still accepted. Prints a warning: "The --adopt flag is deprecated."--adoptreferences from README, CLI reference, FAQ, SKILL.md. Add "Turning Existing Branches into a Stack" section to workflows guide.Stack created with GitHub Stacks CLI • Give Feedback 💬