Branching a session into a copy you can take somewhere else, and going back to an earlier point. Subagents that start from your conversation are on the Subagents page.
Worktrees: create, set up, integrate and clean up isolated checkouts
| Question | Codex CLIchecked at 0.162.1 |
|---|---|
| Fork a session | In the TUI, type
|
| Fork or rewind from an earlier point | Partly You can't fork from an earlier turn in the CLI: The docs say Esc-Esc forks the chat from that point. Since 0.156.0 it rewinds the same chat in place, so the later turns are gone from that chat. To keep them, Rewinding only works on sessions in the newer paginated history format. Older sessions can be converted with The app-server |
| What the fork keeps | A fork copies the full conversation and keeps the current model, reasoning effort, permissions profile, working directory and any active goal. It doesn't keep the session name. You can rename it with A 0.166.0: resume and fork take the approval policy, reviewer and permission profile from the source thread's own most recent accepted settings update, not from a possibly stale turn record. An unnamed permission profile is restored only when the update can be attributed to that thread. Explicit sandbox or permission overrides on the request still win. |
| File changes and worktrees | Partly Forks don't snapshot or rewind files. By default a fork shares the same working directory. In a Git repo, The managed worktree is a detached checkout of the current
|
| Where a fork came from | Partly When a fork opens, Codex prints |
| Fork from the SDK or API | In headless mode, 0.165.0 App Server |
Notes and sources
Codex CLI, 24 sources
Fork or rewind from an earlier point, 5
What the fork keeps, 7
Where a fork came from, 3
Fork from the SDK or API, 10
- codex-rs/app-server-protocol/src/protocol/v2/thread.rs
- codex-rs/app-server-protocol/src/protocol/v2/thread.rs
- codex-rs/app-server/src/request_processors/thread_processor.rs
- codex-rs/app-server/src/request_processors/thread_processor.rs
- codex-rs/app-server/src/request_processors/thread_processor.rs
- thread_delete.rs