Skip to content

feat: copy .worktreeinclude files into new worktrees - #330

Merged
kbwo merged 2 commits into
mainfrom
feature/worktreeinclude-support
Aug 30, 2026
Merged

feat: copy .worktreeinclude files into new worktrees#330
kbwo merged 2 commits into
mainfrom
feature/worktreeinclude-support

Conversation

@kbwo

@kbwo kbwo commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Problem

A new git worktree only gets tracked files, so gitignored files a project needs to actually run — .env, local certs, etc. — don't carry over. ccmanager had no way to copy them automatically; the closest existing feature (copySessionData/copyClaudeDirectory) only copies Claude Code's own session data or .claude/, not arbitrary project files.

.worktreeinclude has emerged as a shared convention for this across worktree-aware tools — Claude Code, Codex, Conductor, and the standalone git-worktreeinclude CLI all read a gitignore-syntax .worktreeinclude file at the repository root and copy the gitignored files it selects into each new worktree. Adopting the same file name and semantics means a .worktreeinclude a user already maintains for those tools works with ccmanager unchanged, instead of requiring a second, ccmanager-specific config for the same thing.

Out of scope: no new config toggle was added — the copy step runs whenever a .worktreeinclude file exists, matching how the other tools behave, so there's nothing to configure.

Verification

Prerequisites:

  • None (bun run test can be run from the repo root)

Steps:

  • bun run typecheck — confirmed it exits with no errors
  • bun run lint — confirmed it exits with no errors
  • bun run test — confirmed all tests pass (1848 passed / 10 skipped), including the new src/utils/worktreeInclude.test.ts integration tests (real git repos: selects a matching+gitignored file, excludes a matching-but-not-ignored file, excludes a tracked file even if it matches, resolves a directory glob pattern, doesn't overwrite an existing destination file)
  • In a real git repo, added a .worktreeinclude listing .env, added .env to .gitignore, created a .env file with SECRET=verify-me, then called WorktreeService.createWorktreeEffect (the same code path the TUI's "create worktree" flow uses) — confirmed the new worktree's .env exists with content SECRET=verify-me

kbwo and others added 2 commits August 25, 2026 17:20
Adopt the .worktreeinclude convention shared by Claude Code, Conductor,
OpenAI Codex, and git-worktreeinclude: a gitignore-syntax file at the
repository root listing gitignored files (e.g. .env) to carry into
every new worktree, so an existing .worktreeinclude a user already has
for those tools works with ccmanager unchanged.

A file is copied only when it both matches a .worktreeinclude pattern
and is actually gitignored (git ls-files --others --ignored
--exclude-from resolves the pattern match; git check-ignore --stdin
confirms real ignore status), so a tracked file is never duplicated
even if it happens to match a pattern. No config flag gates this: it
runs whenever a .worktreeinclude file exists, matching the other
tools' behavior, and non-fatally logs a warning on failure like the
existing .claude directory copy step.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The feature had no user-facing documentation. Add docs/worktree-include.md
covering why a worktree needs gitignored files copied, the shared
.worktreeinclude convention, pattern syntax, the match-and-actually-ignored
selection rule, when the copy runs relative to the post-creation hook, and
how it relates to the existing session-data / .claude copy options.

Link it from README.md with a short overview section next to the other
worktree-creation features, plus a Features bullet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgkE2WS9WzDF3sQrLBFKCA
@kbwo
kbwo merged commit dfbc8b8 into main Aug 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant