Feature request: Share sessions across git worktrees

Resolved 💬 3 comments Opened Jan 25, 2026 by waynermaia Closed Jan 29, 2026

Summary

Claude Code currently stores sessions based on the directory path. However, when using git worktrees, multiple directories share the same underlying .git directory and repository history. It would be valuable if Claude Code could detect this relationship and share sessions across worktrees.

Problem

Git worktrees allow developers to check out multiple branches simultaneously in different directories while sharing the same .git directory. Currently, each worktree directory is treated as a completely separate project by Claude Code, meaning:

  • Sessions started in one worktree are not accessible from another worktree of the same repository
  • Context about the codebase built up in one worktree cannot be leveraged when switching to work in another
  • Developers must re-establish context when moving between worktrees

Proposed Solution

Claude Code could detect when a directory is part of a git worktree setup by checking for the .git file (which points to the main worktree's .git directory) or by using git rev-parse --git-common-dir. Sessions could then be keyed by the common git directory rather than the working directory path, allowing them to be shared across all worktrees of the same repository.

Use Case

When working on multiple features in parallel using git worktrees, it is common to:

  1. Have a main worktree on main branch for reference
  2. Have separate worktrees for different feature branches
  3. Switch between them frequently while developing

Being able to share session context across these worktrees would significantly improve the development workflow, as Claude Code would retain understanding of the codebase architecture, coding conventions, and ongoing discussions regardless of which worktree is currently active.

Additional Context

  • git worktree list can enumerate all worktrees for a repository
  • git rev-parse --git-common-dir returns the shared git directory
  • This feature would be opt-in or could be enabled by default with an option to disable

Thank you for considering this enhancement.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗