Skip to main content

remove_worktree

Function remove_worktree 

Source
pub fn remove_worktree(
    repo: &Repository,
    worktree_path: &Path,
    force: bool,
) -> Result<(), GitError>
Expand description

Remove a linked worktree using the git CLI.

This removes the worktree directory and its git tracking. The main worktree cannot be removed — attempting to do so returns an error.

§Arguments

  • repo - The repository
  • worktree_path - Path to the worktree to remove
  • force - If true, pass --force to allow removal even with uncommitted changes or if the working tree is dirty

§Errors

  • If worktree_path is the main worktree
  • If the git CLI command fails