Skip to content

Desktop app leaves stale temp worktree and blocks switching back to main #14575

Open

Description

@jskoiz

Summary

The Codex desktop app failed to switch branches because Git believed main was already checked out in a different worktree, but that worktree was not visible as an active session in the app.

Error shown in the desktop app:

Failed to switch branch: fatal: 'main' is already used by worktree at '/private/tmp/codex-limit-mainfix'

What happened

Codex appears to have left behind a temp worktree at:

/private/tmp/codex-limit-mainfix

That worktree was still registered with Git, so the app could not switch the current repo back to main.

Expected behavior

If Codex creates a temporary worktree for a session, it should clean it up when the session is closed or no longer active.

If cleanup fails, the app should either:

  • surface the stale worktree clearly in the UI, or
  • offer a "clean up stale worktrees" action

Actual behavior

The app only showed the Git error that main was already used by another worktree. There was no visible active session or branch in the UI that explained why, so it looked like the branch was "stuck".

Workaround

I fixed it manually with:

git worktree list
git worktree remove /private/tmp/codex-limit-mainfix
git worktree prune

After that, switching branches worked again.

Notes

The stale worktree was clean, and there did not appear to be an active process still using it.

Activity

  1. added
    bugSomething isn't working
    appIssues related to the Codex desktop app
    on Mar 13, 2026
  2. github-actions commented on Mar 13, 2026

    @github-actions
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GitappIssues related to the Codex desktop appbugSomething isn't workingworktreesIssues related to worktree management

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions