Overview
Codaph automatically detects and supports git worktrees, allowing you to capture agent sessions across multiple branches simultaneously.When you run
codaph push from a worktree, Codaph scans all worktrees in the repository and imports agent history from each.What are Git Worktrees?
Git worktrees let you check out multiple branches of the same repository simultaneously:~/projects/myapp(main)~/projects/myapp-feature(feature/new-ui)~/projects/myapp-hotfix(hotfix/critical-bug)
How Codaph Handles Worktrees
Automatic Detection
When you initialize Codaph or runcodaph push, it:
- Detects the git repository root via
git rev-parse --show-toplevel - Lists all worktrees using
git worktree list --porcelain - Scopes the project path across all worktrees
- Imports agent history from each worktree’s agent directories
src/lib/git-worktrees.ts:72
Scoped Project Paths
TheresolveScopedProjectPathsForWorktrees() function resolves your project path to all matching worktrees:
src/lib/git-worktrees.ts:72
Parsing Worktree List
Codaph parsesgit worktree list --porcelain output:
src/lib/git-worktrees.ts:34
This extracts absolute paths to all worktrees and deduplicates them.
Relative Suffix Projection
Codaph projects the relative path from repo root to your current location across all worktrees:src/lib/git-worktrees.ts:50
Usage Examples
Enable Worktree Scanning (Default)
- Current worktree
- All other worktrees in the same repository
Disable Worktree Scanning
Example Workflow
myapp-feat1 and myapp-feat2) are imported.
How Import Works
When you runcodaph push, Codaph:
- Resolves worktree paths
- Scans each worktree for agent marker directories:
.codex/(Codex).claude/(Claude Code)~/.config/gemini/(Gemini CLI, not worktree-specific)
- Imports agent history from each location
- Deduplicates events by
eventIdin the local mirror
src/index.ts:1376 (runSyncPushPhase)
Agent History Paths
For each worktree, Codaph checks:Deduplication
Codaph automatically deduplicates events across worktrees using eventId hashing:src/lib/core-types.ts:113
If the same event appears in multiple worktrees (e.g., shared .codex/ directory), it’s imported only once.
Configuration
Disable Worktrees Globally
Add to your project settings:.codaph/project.json
Per-Command Override
Limitations
- Codex and Claude Code are worktree-aware (history stored in
.codex/and.claude/respectively) - Gemini CLI is not worktree-aware (global history)
Troubleshooting
”No worktrees detected”
Rungit worktree list to verify worktrees exist:
Events imported multiple times
If worktrees share the same.codaph/ directory (symlink or bind mount), disable worktrees:
Missing sessions from other worktrees
Verify agent marker directories exist in each worktree:Related
codaph push— Import agent history with worktree support- Agent Providers — Codex, Claude Code, Gemini CLI detection
- Project Settings — Configure worktree behavior
Testing
Tests:test/lib-git-worktrees.test.ts
Codaph includes unit tests for worktree parsing and scoping:
parseGitWorktreeListPorcelain— parsinggit worktree listoutputscopeProjectPathAcrossWorktrees— relative path projectionresolveScopedProjectPathsForWorktrees— end-to-end resolution