Skip to content

gtr clean: add --force flag to handle repos with submodules #160

Description

@echarrod

Problem

gtr clean --merged fails silently when worktrees contain submodules, because the underlying git worktree remove refuses to remove worktrees with submodules:

==> Removing worktree: my-feature
[x] Failed to remove worktree: fatal: working trees containing submodules cannot be moved or removed

This affects any repo that uses git submodules — all worktrees will fail to clean up, making gtr clean --merged essentially unusable in those repos.

Current behaviour

gtr rm already supports --force to bypass this (and the uncommitted-changes check). However, gtr clean has no equivalent flag, so there's no way to clean up merged worktrees in repos with submodules without resorting to manual rm -rf + git worktree prune.

Requested change

Add a --force flag to gtr clean that passes through to the underlying git worktree remove --force call, consistent with how gtr rm --force works.

gtr clean --merged --yes --force

Workaround

Currently the only option is manually removing each worktree directory and running git worktree prune, which loses the merge-detection and other benefits of gtr clean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions