Codex Desktop fails creating worktree for branch

Open 💬 2 comments Opened Jun 29, 2026 by JKamsker
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.623.42026 • Released 27.06.2026

What subscription do you have?

PRO

What platform is your computer?

Linux 7.0.0-15-generic x86_64 unknown | Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

[info] Starting worktree creation
fatal: invalid reference: codex/add-datetime-rpc-support
[stderr] git worktree add failed: fatal: invalid reference: codex/add-datetime-rpc-support

What steps can reproduce the bug?

  • Have a repo on github
  • On remote server, only main is checked out
  • In codex app: Create new worktree from branch which exists on github

What is the expected behavior?

Worktree is being created successfully

Additional information

_No response_

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #30469

Powered by Codex Action

LuccaRomanelli · 1 month ago

Additional data point: this also reproduces when the selected branch exists only as a remote-tracking ref.

Example shape:

  • remote-tracking branch exists: origin/feature/foo
  • local branch does not exist: feature/foo
  • Codex-managed worktree creation fails with fatal: invalid reference: feature/foo

Local validation:

  • git worktree add --detach <path> feature/foo fails with fatal: invalid reference when only origin/feature/foo exists.
  • git worktree add --detach <path> origin/feature/foo works.
  • worktree.guessRemote=true and checkout.defaultRemote=origin do not fix the detached case.

Suggested behavior: when creating a detached Codex-managed worktree, if <branch> is not a valid local ref but origin/<branch> exists, Codex should use origin/<branch> as the commit-ish, or create the local tracking branch automatically before calling git worktree add.