Answer: Add a `.worktreeinclude` file to your project root using `.gitignore` syntax; only files that match a pattern and are also gitignored are copied into each new worktree. For example, a `.worktreeinclude` containing `.env`, `.env.local`, and `config/secrets.json` copies those files into each new worktree. Status: Confirmed Entry: tool/claude-code/settings/worktreeinclude-gitignored-files Revision: 4 Digest: sha256:eeb63af21ad13bcb (changes whenever the content changes) Timeline: Created: 2026-11-13T03:06:09Z Last changed: 2026-11-20T12:26:22Z (example secrets config: — → config/secrets.json) Last verified: 2026-11-20T12:26:22Z Next check: 2026-11-21T12:26:22Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of file to add | .worktreeinclude | [1] | 2026-11-20 syntax | .gitignore | [1] | 2026-11-20 copy condition | Only files that match a pattern and are also gitignored are copied | [1] | 2026-11-20 example env file | .env | [1] | 2026-11-20 example env local file | .env.local | [1] | 2026-11-20 example secrets config | config/secrets.json | [1] | 2026-11-20 version note | v2.1.239 | [1] | 2026-11-20 Sources: [1] Anthropic. "Run parallel sessions with worktrees". https://code.claude.com/docs/en/worktrees.md Role: primary. Accessed: 2026-11-20T12:26:22Z Quote: "add a `.worktreeinclude` file to your project root" (Supports: file to add) Quote: "The file uses `.gitignore` syntax." (Supports: syntax) Quote: "Only files that match a pattern and are also gitignored are copied, so tracked files are never duplicated." (Supports: copy condition) Quote: ".env .env.local config/secrets.json" (Supports: example env file, example env local file, example secrets config) Quote: "Before v2.1.239, Claude Code copied files out of a wholly ignored directory for a `**/` pattern only when the directory itself matched the pattern." (Supports: version note) Published: 2026-11-20T03:10:58Z Snapshot SHA-256: 5b800b1cd50f91f0fb7e85a6810c9f3d3ddfa3d9f191fe64be019213a52257f1 (captured 2026-11-19T12:21:26Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-19T12:21:27Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:26:22Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:26:22Z Last attempt: 2026-11-20T12:26:22Z Notes and limitations: Extracted automatically from a single official source (section "Copy gitignored files into worktrees"). Related: https://latestn.com/tool/claude-code/troubleshooting/auto-mode-classifier-eligibility How do I make a Claude Code session eligible for no-charge auto mode classifier requests? https://latestn.com/tool/claude-code/troubleshooting/auto-mode-classifier-notice-cause Why does Claude Code show the notice that this session isn't eligible for auto mode's no-charge classifier requests? https://latestn.com/tool/claude-code/troubleshooting/aws-gateway-troubleshooting How do I troubleshoot issues when deploying Claude apps gateway on AWS? https://latestn.com/tool/claude-code/settings/turn-off-agent-view How do I turn off agent view in Claude Code? https://latestn.com/tool/claude-code/settings/turn-off-one-step-updates How do I turn off one-step artifact updates in Claude Code? https://latestn.com/tool/claude-code/settings/turn-workflows-on-off How do I turn dynamic workflows on or off in Claude Code? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:26:22Z | changed | example secrets config: — → config/secrets.json | [1] 2026-11-20T12:26:22Z | changed | example env local file: — → .env.local | [1] 2026-11-20T12:26:22Z | changed | example env file: — → .env | [1] 2026-11-20T12:26:22Z | changed | example pattern 3: config/secrets.json → — | [1] 2026-11-20T12:26:22Z | changed | example pattern 2: .env.local → — | [1] 2026-11-20T12:26:22Z | changed | example pattern 1: .env → — | [1] 2026-11-18T12:21:11Z | changed | version note: — → v2.1.239 | [1] 2026-11-18T12:21:11Z | changed | example pattern 3: — → config/secrets.json | [1] 2026-11-18T12:21:11Z | changed | example pattern 2: — → .env.local | [1] 2026-11-18T12:21:11Z | changed | example pattern 1: — → .env | [1] 2026-11-18T12:21:11Z | changed | copy condition: — → Only files that match a pattern and are also gitignored are copied | [1] 2026-11-18T12:21:11Z | changed | syntax: — → .gitignore | [1] 2026-11-18T12:21:11Z | changed | file to add: — → .worktreeinclude | [1] 2026-11-18T12:21:11Z | changed | Version note: v2.1.239 → — | [1] 2026-11-18T12:21:11Z | changed | Example patterns: .env .env.local config/secrets.json → — | [1] 2026-11-18T12:21:11Z | changed | Copy condition: Only files that match a pattern and are also gitignored are copied → — | [1] 2026-11-18T12:21:11Z | changed | Syntax: .gitignore → — | [1] 2026-11-18T12:21:11Z | changed | File to add: .worktreeinclude → — | [1] 2026-11-14T12:22:03Z | changed | Example patterns: — → .env .env.local config/secrets.json | [1] 2026-11-14T12:22:03Z | changed | Example .worktreeinclude contents: .env .env.local config/secrets.json → — | [1] 2026-11-14T12:22:03Z | changed | Example env files: .env → — | [1] 2026-11-13T03:06:09Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/settings/worktreeinclude-gitignored-files/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/settings/worktreeinclude-gitignored-files POST: https://latestn.com/dispute/tool/claude-code/settings/worktreeinclude-gitignored-files with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/settings/worktreeinclude-gitignored-files?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I copy gitignored files like .env into Claude Code worktrees with .worktreeinclude? Revision 4, last verified 2026-11-20T12:26:22Z. https://latestn.com/tool/claude-code/settings/worktreeinclude-gitignored-files (accessed 2026-11-21T09:52:30Z). @misc{LatestN_tool_claude_code_settings_worktreeinclude_gitignored_files_r4, title = {How do I copy gitignored files like .env into Claude Code worktrees with .worktreeinclude?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/settings/worktreeinclude-gitignored-files}}, note = {Revision 4; digest sha256:eeb63af21ad13bcb; last verified 2026-11-20T12:26:22Z; accessed 2026-11-21T09:52:30Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/settings/worktreeinclude-gitignored-files