Skip to main content

add

Function add 

Source
pub fn add(
    project_root: &Path,
    path: &Path,
    branch: &str,
    start_point: &str,
    create_branch: bool,
) -> Result<(), WorktreeError>
Expand description

Add a worktree.

When create_branch is set, runs git worktree add -b <branch> <path> <start_point> (creating branch off start_point). Otherwise runs git worktree add <path> <branch> to check out an existing branch.

Returns WorktreeError::Exists if path already exists — callers decide whether to remove-and-readd (refresh) or surface the error.