Skip to content

Fix pruning git worktrees - #6

Merged
skunkworker merged 6 commits into
masterfrom
jb/2026_10_08_worktree_prune
Oct 8, 2026
Merged

skunkworker merged 6 commits into
masterfrom
jb/2026_10_08_worktree_prune

Conversation

@skunkworker

Copy link
Copy Markdown
Owner

No description provided.

skunkworker and others added 6 commits October 8, 2026 12:00
git refuses to delete a branch that any worktree has checked out, under
-d and -D alike, so pruning such a branch always failed. The delete now
runs `git worktree remove` first, with --force in force mode. A branch
that -d will refuse as unmerged keeps its worktree until the user
accepts the force retry. A branch checked out in the main worktree
cannot be marked, since git cannot remove the main worktree.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Rows mark a branch checked out in another worktree with +, as `git
branch` does. The confirm screen and the force prompt name each worktree
the delete removes, and say whether uncommitted changes are refused or
discarded. The results screen reports each removed worktree. The help
screen and README describe the behavior.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Cover a clean worktree and one whose directory is gone, a dirty
worktree in safe and force mode, an unmerged branch that keeps its
worktree until the force retry, and a branch held by the main worktree.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add safeDeleteRefuses and worktreePending so deleteBranch,
worktreeWarning, forceDeleteUnmerged and the force prompt share one test
each instead of repeating the conditions. The kept-worktree case sets
forceable directly rather than building an error string for the merge
check to find.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
master split main.go into git.go, model.go and view.go and locked every
branch checked out in another worktree. The worktree fix moves into the
new files. Only a branch in the main worktree stays locked; a branch in
a linked worktree is selectable, and its delete removes the worktree
first. Script mode removes worktrees the same way as safe mode.

The confirm screen now also warns that git deletes a worktree's ignored
files, such as .env, which it does not count as changes.

Mark the worktree bug in bugs.md as done.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A worktree is scratch space for its branch, so the delete now runs `git
worktree remove --force` in safe and force mode alike. Safe mode no
longer refuses a worktree with uncommitted changes. A locked worktree
is still refused, and an unmerged branch still keeps its worktree until
the force retry, since the commits are the work at risk there.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@skunkworker
skunkworker merged commit b18a33c into master Oct 8, 2026
2 checks passed
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