To avoid re-downloading dependencies and rebuilding artifacts when using multiple Git worktrees, configure shared Bazel caches in your global ~/.bazelrc:
--disk_cache: Stores compiled action outputs.--repository_cache: Stores downloaded external dependencies.
Note: These directories grow unbounded and should be pruned periodically. Keep them on the same filesystem as your checkouts to allow Bazel to use hardlinks.
Self-cleaning Worktrees (macOS/Linux)
To prevent the Bazel output base from leaking disk space when deleting worktrees, point the output base inside the worktree by adding this to the worktree's .bazelrc.local:
startup --output_base=.local/output-base.
Windows Note
Do not nest the output base inside the repo on Windows due to path-length limits. Instead, use startup --output_user_root=C:/tmp in selenium/.bazelrc.windows.local.
# Add to ~/.bazelrc
common --disk_cache=/path/to/your/home/.cache/bazel-disk
common --repository_cache=/path/to/your/home/.cache/bazel-repo
# Add to worktree/.bazelrc.local (macOS/Linux)
startup --output_base=.local/output-base