Skip to main content

worktree_add_detached

Function worktree_add_detached 

Source
pub fn worktree_add_detached(path: &Path, commit: &str) -> Result<()>
Expand description

Add a detached worktree at path, parked on commit. Detached on purpose: it holds no branch, so it cannot collide with the user’s checkout or any other worktree.

--force because path is a scratch directory git-stk owns outright: a killed run can leave the directory gone but still registered, and git then refuses the path as “a missing but already registered worktree”. Forcing is scoped to that one path - git worktree prune would also clear entries for the user’s own worktrees that happen to be on unmounted volumes.