This repository was archived by the owner on Feb 24, 2026. It is now read-only.
fix: clean up empty parent directories after worktree removal#41
Merged
davidpoblador merged 1 commit intomainfrom Feb 9, 2026
Merged
fix: clean up empty parent directories after worktree removal#41davidpoblador merged 1 commit intomainfrom
davidpoblador merged 1 commit intomainfrom
Conversation
When using nested branch names like `fix/issue-x`, removing the worktree leaves empty parent directories behind. Add a loop to both wt-rm and wt-destroy that walks up from the target's parent, removing empty directories until it hits the project root or a non-empty directory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
wt-rmorwt-destroyremoves a worktree with a nested branch name (e.g.,fix/issue-x), empty parent directories likefix/were left behindtype/scope/name) and is safe when sibling worktrees share a prefixTest plan
wt-add fix/test-1thenwt-rm fix/test-1—fix/directory is removedwt-add fix/aandwt-add fix/b, thenwt-rm fix/a—fix/still exists (hasfix/b)wt-rm fix/b—fix/is now removedwt-add deep/nested/branch, thenwt-destroy deep/nested/branch— bothdeep/nested/anddeep/are removedwt-add flat-branch, thenwt-rm flat-branch— no parent cleanup needed, works as before🤖 Generated with Claude Code