cargo-worktree is a thin Cargo wrapper for git worktrees.
It keeps Cargo's normal behavior, but isolates target/ by branch or commit so parallel worktrees do not block or overwrite each other's build output.
Cargo shares one target/ by default. That is fine for one branch, but in a worktree workflow it can cause:
- build output being overwritten
- incorrect incremental reuse
- noisy concurrent builds and tests
- parallel builds (multiple worktrees) contend on the same directory
cargo-worktree keeps Cargo's command line familiar, but makes the output path worktree-aware.
cargo install cargo-worktreeOr install from a local checkout:
cargo install --path .Use it like Cargo:
cargo worktree build
cargo worktree test
cargo worktree run
cargo worktree check
cargo worktree clippy
cargo worktree bench
cargo worktree fmt
Anything else is forwarded too:
cargo worktree clean
cargo worktree test -- --nocapture
cargo worktree clippy -- -D warnings
cargo worktree metadata --format-version 1- Branch checkout:
target/git/<branch> - Detached HEAD:
target/git/<commit> - Not in git: use Cargo's default
target/
Check what the wrapper resolved with:
cargo worktree inspectMIT