Skip to content

[Feature Request] When deleting a branch, also delete its worktree #2469

@ablekhman

Description

@ablekhman

When user deletes a branch and there is associated worktree, then Fork proceeds with deletion, but then fails with unexpected error:

error: cannot delete branch 'branch-name' used by worktree at '/path/to/worktree'

The error is expected because Fork knows that there is worktree attached to the branch.
The scenario could be improved by deleting the worktree together with the branch in one go.

When deleting a worktree with uncommitted changes, then Fork proceeds with deletion, but then fails with unexpected error:

fatal: '/path/to/worktree' contains modified or untracked files, use --force to delete it

This error is also expected because Fork knows that there are uncommitted files.
The delete worktree dialog could have a checkbox: "Force delete".

Ideally, I would like to be able to delete a branch with its worktree and all uncommitted changes in one go. Like this:

$ git worktree remove -f /path/to/worktree && git branch -D branch-name  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions