Summary
When spawning a new git worktree, builds start from scratch because no build artifacts are carried over. Copying existing build artifacts (e.g., target/, node_modules/.cache, .svelte-kit) into the new worktree would enable incremental builds and significantly reduce initial compile times.
Details
Currently, git worktree add creates a clean working directory with no build artifacts. For Rust/Tauri projects, this means a full cargo build from zero on every new worktree — often taking several minutes.
If we copy (or hard-link) the target/ directory and other cacheable artifacts from the source worktree into the new one, subsequent builds can leverage incremental compilation and only rebuild what changed.
Proposed approach:
- After
git worktree add, copy key build artifact directories from the parent worktree
- Use hard links or
cp -al where possible to save disk space and time
- Directories to consider:
src-tauri/target/, node_modules/, .svelte-kit/
Considerations:
- Hard links vs full copies (trade-off: speed/space vs isolation)
- Some artifacts may contain absolute paths that need invalidation
- Should be opt-in or configurable in case it causes issues
Summary
When spawning a new git worktree, builds start from scratch because no build artifacts are carried over. Copying existing build artifacts (e.g.,
target/,node_modules/.cache,.svelte-kit) into the new worktree would enable incremental builds and significantly reduce initial compile times.Details
Currently,
git worktree addcreates a clean working directory with no build artifacts. For Rust/Tauri projects, this means a fullcargo buildfrom zero on every new worktree — often taking several minutes.If we copy (or hard-link) the
target/directory and other cacheable artifacts from the source worktree into the new one, subsequent builds can leverage incremental compilation and only rebuild what changed.Proposed approach:
git worktree add, copy key build artifact directories from the parent worktreecp -alwhere possible to save disk space and timesrc-tauri/target/,node_modules/,.svelte-kit/Considerations: