Skip to main content
Create a new worktree from a branch, pull request, or issue without launching the TUI.

Syntax

lazyworktree create [options] [name]

Options

name
string
Optional worktree and branch name. If not provided, the name is automatically generated by sanitising the source branch name (lowercase, alphanumeric characters and hyphens only).
--from-branch
string
Create worktree from the specified branch. If not provided, uses the current branch from the working directory.
--from-pr
integer
Create worktree from PR number. Fetches the specified PR and generates the worktree name from pr_branch_name_template.PR Creation Behavior: The worktree always uses the generated name. The local branch name is conditional: if you are the PR author, lazyworktree keeps the PR branch name; otherwise it uses the generated name. When requester identity cannot be resolved, lazyworktree falls back to the PR branch name.
--from-issue
integer
Create worktree from issue number. Fetches the specified issue and creates a worktree with a sanitised branch name derived from the issue_branch_name_template (default: issue--). Uses the current branch as the base; combine with --from-branch to specify a different base.
-I, --from-issue-interactive
boolean
Interactively select an open issue to create a worktree from. When fzf is installed, presents a searchable list with issue body preview; otherwise displays a numbered list for selection. Combine with --from-branch to specify a base branch.
-P, --from-pr-interactive
boolean
Interactively select an open pull request to create a worktree from. When fzf is installed, presents a searchable list with PR metadata preview; otherwise displays a numbered list for selection.
-q, --query
string
Pre-filter the interactive selection list. Requires -I or -P. When fzf is available, the search box is pre-filled with the given string; otherwise the numbered list is filtered to items containing the string (case-insensitive).
--generate
boolean
Generate worktree name automatically from the current branch name. Cannot be used with a positional name argument or with --from-pr-interactive. Sanitises the branch name to be Git-compatible (lowercase, alphanumeric characters and hyphens only).
--with-change
boolean
Carry over uncommitted changes to the new worktree. Works with current branch or --from-branch. Cannot be used with --from-pr or --from-issue. Stashes changes from current worktree, creates new worktree, and applies the stash.
--no-workspace
boolean
Skip worktree creation entirely. Instead, creates a local branch and switches to it in the current working directory. Must be used with --from-pr, -P, --from-issue, or -I. Outputs the branch name rather than a worktree path.
--exec
string
Run a shell command after creation. The command runs in the created worktree directory, or in the current directory when used with --no-workspace. Shell mode follows your current shell (zsh -ilc, bash -ic, otherwise -lc).
--silent
boolean
Suppress all progress messages to stderr. Only the worktree path is written to stdout unless --output-selection is used.
--output-selection
string
Write the created worktree path to a file. When set, stdout output is suppressed.

Examples

Basic Creation

# Auto-generated from current branch
lazyworktree create

# Explicit name
lazyworktree create my-feature

# From specific branch
lazyworktree create --from-branch main my-feature

From Pull Requests

# Create from PR number
lazyworktree create --from-pr 123

# Interactively select PR
lazyworktree create -P

# Pre-filter interactive PR selection
lazyworktree create -P -q "dark"

# Branch only, no worktree
lazyworktree create --from-pr 123 --no-workspace

From Issues

# From issue (base: current branch)
lazyworktree create --from-issue 42

# From issue with explicit base
lazyworktree create --from-issue 42 --from-branch main

# Interactively select issue
lazyworktree create -I

# Pre-filter interactive issue selection
lazyworktree create -I --query "login"

# Branch only, no worktree
lazyworktree create --from-issue 42 --no-workspace

Advanced Options

# With uncommitted changes
lazyworktree create my-feature --with-change

# Run command after creation
lazyworktree create my-feature --exec 'npm test'

Build docs developers (and LLMs) love