Skip to content

git worktree-init

Initialize a new repository in the worktree-based directory structure

TIP

This command is also available as daft init. See daft init.

Description

Initializes a new Git repository using the same directory structure as git-worktree-clone(1). The resulting layout is:

<name>/.git      (bare repository metadata)
<name>/<branch>  (worktree for the initial branch)

This structure is optimized for worktree-based development, allowing multiple branches to be checked out simultaneously as sibling directories.

The initial branch name is determined by, in order of precedence: the -b option, the init.defaultBranch configuration value, or "master" as a fallback.

If the repository contains a .daft/hooks/ directory (created manually after init) and is trusted, lifecycle hooks are executed. See git-daft(1) for hook management.

Usage

git worktree-init [OPTIONS] <REPOSITORY_NAME>

Arguments

ArgumentDescriptionRequired
<REPOSITORY_NAME>Name for the new repository directoryYes

Options

OptionDescriptionDefault
--bareCreate only the bare repository; do not create an initial worktree
-q, --quietOperate quietly; suppress progress reporting
-v, --verboseBe verbose; show detailed progress
-b, --initial-branch <INITIAL_BRANCH>Use <name> as the initial branch instead of the configured default
-r, --remote <REMOTE>Organize worktree under this remote folder (enables multi-remote mode)
--no-cdDo not change directory to the new worktree
--layout <LAYOUT>Worktree layout to use for this repository
-x, --exec <EXEC>Run a command in the worktree after setup completes (repeatable)

Global Options

OptionDescription
-h, --helpPrint help information
-V, --versionPrint version information

See Also

Released under the MIT License.