Skip to content

Share persistent build cache across git worktrees #33321

@aqeelat

Description

@aqeelat

Command

build, serve

Description

Git worktrees allow multiple checkouts of the same repository. Each worktree currently gets its own .angular/cache directory with nearly identical contents, since they share the same source tree.

In our project, 4 active frontend worktrees consume ~140 GB of duplicated cache data. This is a significant and unnecessary disk cost.

Nx handles this automatically — when it detects a git worktree, it shares a single cache directory across all worktrees of the same repository.

Describe the solution you'd like

When the CLI detects a git worktree (via .git being a file pointing to a common git directory), resolve the default cache path relative to the common git directory instead of the worktree root. This shares one cache across all worktrees without requiring user configuration.

This is the same approach Nx uses and would make Angular's behavior consistent with Nx for the large number of projects using both together.

Describe alternatives you've considered

  • Manually setting cli.cache.path to a shared absolute path in angular.json — works but requires manual per-project configuration, is easy to forget, and the path is easy to accidentally commit to version control.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions