René's URL Explorer Experiment


Title: gh stack rebase --upstack doesn't detect squash-merged branches below the current branch · Issue #31 · github/gh-stack · GitHub

Open Graph Title: gh stack rebase --upstack doesn't detect squash-merged branches below the current branch · Issue #31 · github/gh-stack

X Title: gh stack rebase --upstack doesn't detect squash-merged branches below the current branch · Issue #31 · github/gh-stack

Description: Summary When gh stack rebase --upstack is run from a branch that has a squash-merged PR somewhere below it in the stack, the merged branch is never detected and skipped. Pre-squash commits from the merged branch stay in the history of ev...

Open Graph Description: Summary When gh stack rebase --upstack is run from a branch that has a squash-merged PR somewhere below it in the stack, the merged branch is never detected and skipped. Pre-squash commits from the...

X Description: Summary When gh stack rebase --upstack is run from a branch that has a squash-merged PR somewhere below it in the stack, the merged branch is never detected and skipped. Pre-squash commits from the...

Opengraph URL: https://github.com/github/gh-stack/issues/31

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"gh stack rebase --upstack doesn't detect squash-merged branches below the current branch","articleBody":"## Summary\n\nWhen `gh stack rebase --upstack` is run from a branch that has a squash-merged PR somewhere below it in the stack, the merged branch is never detected and skipped. Pre-squash commits from the merged branch stay in the history of every branch above, which (after push) shows up as bloated PR diffs containing unrelated code from the already-merged PR.\n\n## Reproducer\n\n1. Create a stack `main ← A ← B ← C` with PRs for each.\n2. Squash-merge A's PR into main.\n3. From B or C, run `gh stack rebase --upstack`.\n4. Observe: B and C are rebased but still contain A's pre-squash commits.\n5. The PRs for B and C now show a diff that includes A's changes in addition to their own.\n\nPlain `gh stack rebase` (no flag) handles the same scenario correctly — it detects A as merged, sets `needsOnto`, and rebases B and C with `--onto` to skip A's pre-squash commits.\n\n## Root cause\n\nIn `cmd/rebase.go`:\n\n```go\nif opts.upstack {\n    startIdx = currentIdx\n}\nbranchesToRebase := s.Branches[startIdx:endIdx]\n```\n\nThe squash-merge detection runs inside the loop that iterates over `branchesToRebase`:\n\n```go\nif br.IsMerged() {\n    ontoOldBase = originalRefs[br.Branch]\n    needsOnto = true\n    cfg.Successf(\"Skipping %s (PR %s merged)\", br.Branch, ...)\n    continue\n}\n```\n\n`--upstack` sets `startIdx = currentIdx`, so any merged branch below `currentIdx` is excluded from the slice. `IsMerged()` never fires on it, `needsOnto` stays `false`, and the subsequent rebases use the old (pre-squash) parent instead of `--onto` to the squashed base.\n\n## Suggested fixes\n\nTwo options:\n\n1. **Seed merge state before the upstack loop.** Scan `s.Branches[:startIdx]` for merged branches before starting the loop and, if any is found, pre-populate `ontoOldBase` / `needsOnto` with the appropriate old base so that the first branch in the upstack slice rebases with `--onto`.\n\n2. **Refuse `--upstack` when a merged branch exists below.** Detect the condition up front and error out with a message directing the user to run plain `gh stack rebase` instead. Simpler and surfaces the problem loudly rather than silently producing a bad rebase.\n\nOption 2 is probably cheapest and prevents silent data corruption. Option 1 is more user-friendly but needs more care around multiple merged branches in sequence.\n\n## Impact\n\nRepeatedly observed in the wild — the bad rebase is silent, the push succeeds, and the only signal is that PRs suddenly show hundreds of lines of unrelated diff. Easy to miss if you don't self-check every push.","author":{"url":"https://github.com/benschoel","@type":"Person","name":"benschoel"},"datePublished":"2026-04-15T20:22:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/31/gh-stack/issues/31"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5d16ff0c-61f7-01a8-67ce-727cdaca3d74
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDA82:16C3D3:6369003:8BCC7E9:6A5028EA
html-safe-noncec96dd870cd8ec1723e633814cd3ce7ff135ab8504383a699112e6c27b214296c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTgyOjE2QzNEMzo2MzY5MDAzOjhCQ0M3RTk6NkE1MDI4RUEiLCJ2aXNpdG9yX2lkIjoiMzc3ODA1MDg5NDAzNTE2NzQ2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac659b5334244e6060e94fab86fcc343a9b5cb4f153f6e96a845af887666e134e0
hovercard-subject-tagissue:4271473442
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/gh-stack/31/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3fdbe03e235a0e644a3d9078222d5dfbd4c071a293fc21dcd322a92e5d6c1b9f/github/gh-stack/issues/31
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3fdbe03e235a0e644a3d9078222d5dfbd4c071a293fc21dcd322a92e5d6c1b9f/github/gh-stack/issues/31
og:image:altSummary When gh stack rebase --upstack is run from a branch that has a squash-merged PR somewhere below it in the stack, the merged branch is never detected and skipped. Pre-squash commits from the...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebenschoel
hostnamegithub.com
expected-hostnamegithub.com
Noned6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb
turbo-cache-controlno-preview
go-importgithub.com/github/gh-stack git https://github.com/github/gh-stack.git
octolytics-dimension-user_id9919
octolytics-dimension-user_logingithub
octolytics-dimension-repository_id1151630728
octolytics-dimension-repository_nwogithub/gh-stack
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1151630728
octolytics-dimension-repository_network_root_nwogithub/gh-stack
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released90666eaf032b7eb8975a378efe38e37f4ebb96c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/github/gh-stack/issues/31#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fgh-stack%2Fissues%2F31
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fgh-stack%2Fissues%2F31
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=github%2Fgh-stack
Reloadhttps://github.com/github/gh-stack/issues/31
Reloadhttps://github.com/github/gh-stack/issues/31
Reloadhttps://github.com/github/gh-stack/issues/31
Please reload this pagehttps://github.com/github/gh-stack/issues/31
github https://github.com/github
gh-stackhttps://github.com/github/gh-stack
Notifications https://github.com/login?return_to=%2Fgithub%2Fgh-stack
Fork 18 https://github.com/login?return_to=%2Fgithub%2Fgh-stack
Star 511 https://github.com/login?return_to=%2Fgithub%2Fgh-stack
Code https://github.com/github/gh-stack
Issues 25 https://github.com/github/gh-stack/issues
Pull requests 5 https://github.com/github/gh-stack/pulls
Discussions https://github.com/github/gh-stack/discussions
Actions https://github.com/github/gh-stack/actions
Projects https://github.com/github/gh-stack/projects
Models https://github.com/github/gh-stack/models
Security and quality 0 https://github.com/github/gh-stack/security
Insights https://github.com/github/gh-stack/pulse
Code https://github.com/github/gh-stack
Issues https://github.com/github/gh-stack/issues
Pull requests https://github.com/github/gh-stack/pulls
Discussions https://github.com/github/gh-stack/discussions
Actions https://github.com/github/gh-stack/actions
Projects https://github.com/github/gh-stack/projects
Models https://github.com/github/gh-stack/models
Security and quality https://github.com/github/gh-stack/security
Insights https://github.com/github/gh-stack/pulse
Bughttps://github.com/github/gh-stack/issues?q=type:"Bug"
#43https://github.com/github/gh-stack/pull/43
gh stack rebase --upstack doesn't detect squash-merged branches below the current branchhttps://github.com/github/gh-stack/issues/31#top
#43https://github.com/github/gh-stack/pull/43
https://github.com/skarim
https://github.com/benschoel
benschoelhttps://github.com/benschoel
on Apr 15, 2026https://github.com/github/gh-stack/issues/31#issue-4271473442
skarimhttps://github.com/skarim
Bughttps://github.com/github/gh-stack/issues?q=type:"Bug"
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.