1 stable release
Uses new Rust 2024
| 1.0.0 | Mar 26, 2026 |
|---|
#83 in #git-worktree
19KB
417 lines
cargo-worktree
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.
Goals
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.
Install
cargo install cargo-worktree
Or install from a local checkout:
cargo install --path .
Use
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
Target layout
- 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 inspect
License
MIT
Dependencies
~4–17MB
~224K SLoC