# cargo-worktree
[](https://crates.io/crates/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
```bash
cargo install cargo-worktree
```
Or install from a local checkout:
```bash
cargo install --path .
```
## Use
Use it like Cargo:
```bash
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:
```bash
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:
```bash
cargo worktree inspect
```
## License
MIT