stacks should be shared across worktrees

Problem to solve

When I’m working with stacks on Git worktrees, I expect stacks to be shared across all worktrees for the same repository.

Right now, StackLocation() in internal/git/stacked.go uses git rev-parse --git-dir. In a linked worktree, that points to the worktree’s private Git admin directory .git/worktrees/<name>, which means each worktree gets its own separate copy of the stack metadata.

That makes stacks created in one worktree/or on main repo invisible in another.

Worktrees are rising in popularity now, as AI agents are adopting them for parallel work.

Proposal

Store stack metadata in the shared repository Git directory instead of the per-worktree Git directory.

In practice, that means using git rev-parse --git-common-dir instead of --git-dir

to keep this backward compatible we can migrate any existing stack metadata from the worktree-specific location if it already exists.

Further details