Skip to content

feat(cli): prune local branches with no worktree - #99

Draft
lettertwo wants to merge 3 commits into
mainfrom
prune-branch-rows
Draft

feat(cli): prune local branches with no worktree#99
lettertwo wants to merge 3 commits into
mainfrom
prune-branch-rows

Conversation

@lettertwo

@lettertwo lettertwo commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Background

When a stack of two or more PRs merges while a worktree has one of the stack's branches checked out, git workon prune removes that worktree and deletes its branch, then stops. The other branches in the stack stay behind as local branches, since prune only ever considered branches through the worktree that had them checked out.

This problem is compounded for gh-stack users: gh-stack does not configure upstreams on branches, and a squash merge makes it impossible to tell when a branch was merged. As a result, PR merge status is the only reliable signal that can reach a merged stack's leftovers, which to date has not factored into any pruning decisions.

Change

This PR adds branch-only rows to prune. Every local branch with no worktree (minus the default branch, protected globs, and any branch checked out in a worktree, including the default one) joins the candidate pool and is evaluated for the same signals as a worktree row: PrMerged always, RemoteGone under --gone, Merged under --merged.

  • On by default. --no-branches or workon.pruneBranches = false opts out. --keep-branch drops branch rows entirely.
  • Branch rows show as (no worktree) in dry-run and carry a no worktree, ... annotation in the picker. Prompts and the success line count worktrees and branches separately.
  • --json entries gain "kind": "worktree" | "branch", and a branch row's path is null.
  • Named mode matches a branch-only row by branch name, with the same "not prunable, use --force" rule for a healthy one.

Stack created with GitHub Stacks CLIGive Feedback 💬

@lettertwo lettertwo changed the title prune branch rows feat(cli): prune local branches with no worktree Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant