Skip to content

git worktree-exec ​

Run a command across one or more worktrees

TIP

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

Description ​

Runs one or more commands against one or more selected worktrees without changing the current directory.

Targets may be given as positional branch or worktree-directory names, or globs against branch names (e.g. 'feat/*'). Use --all to target every worktree in the repository. Positionals and --all are mutually exclusive.

Commands are expressed either as a literal argv after --, or as one or more -x shell strings. The two forms are mutually exclusive. Multiple -x values run sequentially per worktree; a failure stops that worktree but does not stop other worktrees.

When you name a single explicit target — one positional branch/worktree name, or a bare --repo — stdio is fully inherited, making interactive programs (claude, vim, fzf) work the same as if you had cd'd into the worktree first.

On an interactive terminal, fan-out runs (--all, a glob, --all-repos, --related, or several positionals) render a live rail: one row per worktree, filled in place, persisted as a receipt — even when the selection resolves to a single worktree. Failed worktrees thread their captured output under their row; pass -v to thread every worktree's output (and, when stdout is redirected, dump successful worktrees' output too). The flag has no effect on single-target pass-through runs (stdio is already inherited).

Usage ​

git worktree-exec [OPTIONS] [TARGETS] [CMD]

Arguments ​

ArgumentDescriptionRequired
<TARGETS>Target worktree(s) by branch name, directory name, or globNo
<CMD>Trailing command vector after --. Mutually exclusive with -xNo

Options ​

OptionDescriptionDefault
--allTarget every worktree in the repository
--repo <REPO>Run in another cataloged repository (targets and --all apply there)
--all-reposRun in every cataloged repository's default-branch worktree
--relatedRun across this repo and its related repos (relations manifest), in each one's worktree for the current branch
-x, --exec <CMD>Shell command to run (repeatable); runs via $SHELL -c
--sequentialRun worktrees one at a time and stop on first failure
--keep-goingRun worktrees one at a time and continue through failures
--refresh-aliasesRe-capture user shell aliases instead of using the cached snapshot
-v, --verboseThread each worktree's full output into the rail and dump captured output for successful worktrees too (no-op for single-target pass-through runs). On a terminal, press v during a run to toggle threading either way

Global Options ​

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

See Also ​

Released under MIT or Apache-2.0.