Answer: Codex creates worktrees in `$CODEX_HOME/worktrees`, starting from the `HEAD` commit of the branch selected when you start your chat, and applies any uncommitted local changes to the worktree. The worktree isn't checked out as a branch but is in a detached HEAD state, which lets Codex create several worktrees without polluting your branches. Status: Confirmed Entry: tool/codex/features/managed-worktree-cleanup Revision: 1 Digest: sha256:04fac19d5b333a03 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:51:02Z Last changed: 2026-11-13T03:51:02Z Last verified: 2026-11-20T13:39:20Z Next check: 2026-11-21T13:39:20Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Worktree location | $CODEX_HOME/worktrees | [1] | 2026-11-20 Starting commit | HEAD | [1] | 2026-11-20 Local changes handling | Codex applies the uncommitted changes to the worktree as well | [1] | 2026-11-20 Checkout state | detached HEAD | [1] | 2026-11-20 Purpose | This lets Codex create several worktrees without polluting your branches | [1] | 2026-11-20 Sources: [1] OpenAI. "Worktrees". https://learn.chatgpt.com/docs/environments/git-worktrees.md Role: primary. Accessed: 2026-11-20T13:39:20Z Quote: "Codex creates worktrees in `$CODEX_HOME/worktrees`." (Supports: Worktree location) Quote: "The starting commit is the `HEAD` commit of the branch selected when you start your chat." (Supports: Starting commit) Quote: "If you chose a branch with local changes, Codex applies the uncommitted changes to the worktree as well." (Supports: Local changes handling) Quote: "It's in a [detached HEAD](https://git-scm.com/docs/git-checkout#_detached_head) state." (Supports: Checkout state) Quote: "This lets Codex create several worktrees without polluting your branches." (Supports: Purpose) Snapshot SHA-256: a40b85b40e9166a59043f62251565500c35c4376e23261f6cb94fdace0824ef6 (captured 2026-11-13T03:51:01Z) 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-13T03:51:02Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:39:20Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:39:20Z Last attempt: 2026-11-20T13:39:20Z Notes and limitations: Extracted automatically from a single official source (section "How Codex manages worktrees for you"). Related: https://latestn.com/tool/codex/features/mobile-advantages What can I do with Codex on mobile, like reviewing changed code and sending instructions? https://latestn.com/tool/codex/features/open-source-components-locations Where can I find the open-source components of Codex, like the CLI and SDK? https://latestn.com/tool/codex/features/remote-capabilities What can I do remotely with Codex on mobile, like approving commands or reviewing diffs? https://latestn.com/tool/codex/features/first-scan-baseline How do I use my first Codex Security scan as a baseline? https://latestn.com/tool/codex/features/follow-scan-progress How do I follow the progress of a Codex Security scan? https://latestn.com/tool/codex/features/handoff-local-worktree How do I hand off a Codex chat between Local and Worktree? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:51:02Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/codex/features/managed-worktree-cleanup/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/codex/features/managed-worktree-cleanup POST: https://latestn.com/dispute/tool/codex/features/managed-worktree-cleanup with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/codex/features/managed-worktree-cleanup?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How does Codex manage and clean up worktrees automatically? Revision 1, last verified 2026-11-20T13:39:20Z. https://latestn.com/tool/codex/features/managed-worktree-cleanup (accessed 2026-11-21T09:52:57Z). @misc{LatestN_tool_codex_features_managed_worktree_cleanup_r1, title = {How does Codex manage and clean up worktrees automatically?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/codex/features/managed-worktree-cleanup}}, note = {Revision 1; digest sha256:04fac19d5b333a03; last verified 2026-11-20T13:39:20Z; accessed 2026-11-21T09:52:57Z} } 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/codex/features/managed-worktree-cleanup