unify-worktree-memory

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

unify-worktree-memory

unify-worktree-memory

Open
@references/guide.md
and follow it. Do not proceed without it.
Consolidate Claude Code's per-project memory across git worktrees so every branch of the same repo shares accumulated knowledge. The solution uses symlinks (Claude Code follows them transparently) and a SessionStart hook for automatic setup of future worktrees.
The guide contains:
  • How Claude Code memory paths work and why worktrees fragment them
  • One-time consolidation script for existing worktrees
  • SessionStart hook for automatic future worktree handling
  • Path encoding rules and prefix collision disambiguation
  • Edge cases: orphaned worktrees, ambiguous repo name prefixes, content merging
打开
@references/guide.md
并按照其中说明操作。未查看该文档请勿继续。
在git worktrees中整合Claude Code的每个项目记忆,使同一仓库的所有分支共享积累的知识。该方案使用符号链接(symlinks,Claude Code可透明识别它们)和SessionStart hook,为未来的worktree自动完成设置。
该指南包含以下内容:
  • Claude Code记忆路径的工作原理,以及为何worktrees会导致记忆碎片化
  • 用于现有worktrees的一次性整合脚本
  • 用于自动处理未来worktree的SessionStart hook
  • 路径编码规则与前缀冲突消除方法
  • 边缘情况:孤立worktrees、仓库名称前缀模糊、内容合并