gh-stack icon indicating copy to clipboard operation
gh-stack copied to clipboard

No way to delete a stack locally whose branches are deleted

Open rd-borislav-rangelov opened this issue 3 months ago • 1 comments

Context

Our repo has the "Delete head on merge" option, which makes it so that when merging a stack from the GitHub website, the feature branches get deleted also. Locally, I also ran gh stack sync which prompted me to prune the branches.

The stack remained for some reason (I see there's a related bug), so I tried to unstack it locally since it no longer existed on remote.

Issue / Feature request

I expected that gh stack unstack --local would destroy the stack even if the branches do not exist but it failed.

To clean my local repo, I had to re-create the branches in the stack with the same names and then unstack succeeded.

Is it possible to have unstack in the case where both the local & remote branches no longer exist to consider them pruned, skip them, and not fail?

rd-borislav-rangelov avatar Aug 13 '26 06:08 rd-borislav-rangelov

I ran into this on v0.3.0 with several merged stacks sharing develop as their trunk. All eight still appeared in the picker.

Since sync --prune explicitly preserves stack metadata, would a dedicated gh stack prune make sense? I'd like to run it once from develop and have it remove local tracking for every stack whose PRs have all merged, even if the feature branches are already gone. Any stack with an open PR or an unpublished layer should stay tracked.

Automatic cleanup when the last PR merges would also solve this for me. The main thing I’m missing is a way to clear completed stacks without selecting each one or recreating deleted branches. I also reproduced the individual unstack --local failure reported in #439.

eluchsinger avatar Nov 30 '26 09:11 eluchsinger