-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Feature Request
Summary
Add a --force / -f flag to git gtr clean (specifically for --merged) that bypasses the dirty-worktree safety check. This allows removing worktrees even when they contain uncommitted changes or untracked files.
Current Behavior
Currently, clean --merged skips any worktree that has uncommitted changes or untracked files to prevent accidental data loss.
(Reference: _clean_should_skip in lib/commands/clean.sh)
While this is a sensible default, it can be tedious when you know the changes are disposable (e.g., build artifacts or experimental logs) and the branch is already safely merged.
Proposed Change
Add -f / --force to the clean command. When this flag is provided:
- The uncommitted changes check is skipped.
- The untracked files check is skipped.
Note on Safety:
- This flag only bypasses the "dirty" check.
- It does not imply
--yes. Users will still be prompted for confirmation unless--yesis also provided. - Detached HEAD worktrees and the current active worktree should still be protected/skipped.
Usage
# Force remove merged worktrees even if dirty
git gtr clean --merged --force
# Combined with auto-confirm
git gtr clean --merged -f --yesI'm happy to contribute and open a PR if the approach looks good to you. Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels