Sessions silently switch git branch when another session opens a different branch

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When multiple Cursor agent/chat sessions are open on the same workspace, opening or switching a different git branch in one session silently changes the active branch metadata (and sometimes the working tree context) for other already-open sessions.

This happens without an explicit checkout in the affected session. The UI branch indicator and agent tooling (e.g. SetActiveBranch / merge-base diffs / PR context) can flip to the other session’s branch while the user still believes they are on the original branch.

Impact: agents and humans can edit, commit, or review against the wrong branch; Multitask/background workers inherit the wrong branch context; recovery requires manually re-asserting the intended branch.

Steps to Reproduce

  1. Open Session A on branch main (or any branch) and leave it open.
  2. Start a new Session B that checks out or is associated with a different branch (e.g. a feature branch).
  3. Return to Session A without manually changing branches.
  4. Observe Session A’s branch indicator / agent branch metadata — it has silently switched to Session B’s branch.

Expected Behavior

Session A remains on its original branch (main). Branch association is per-session (or at least does not change silently without user confirmation).

Operating System

MacOS

Version Information

Version: 3.10.20
Commit: 23b9fb205fe595ea2be29da7214e19762d037fc0
Arch: arm64
OS: macOS (darwin 25.5.0)

For AI issues: which model did you use?

Grok 4.5 (parent); Composer 2.5 (subagents)

Additional Information

Actual

Session A’s UI and/or working context silently switches to Session B’s branch. The user only notices later (e.g. branch indicator in the session UI). Git checkout may or may not have changed; the session branch metadata and UI can diverge from user intent.

Impact

  • Agents may edit/commit on the wrong branch
  • Review/fix loops can land work on unintended branches
  • Risk of data loss or hard-to-recover branch confusion when multiple sessions run in parallel

Notes

  • Reproduced across multiple sessions in the same workspace
  • User did not request a branch switch in the older sessions
  • Please treat as high severity: silent branch changes across sessions
  • Observed with Multitask / background agents and SetActiveBranch / merge-base UI metadata
  • Observing this for past 1 month at least

Does this stop you from using Cursor

YES

Screenshot:

Hey there!

This isn’t a per-session branch setting being silently overwritten. In the desktop IDE, every agent and chat session you open on the same folder shares one Git checkout, so switching the branch in any session (including a switch an agent or subagent makes) changes it for all of them. Each session’s branch indicator then follows that one shared checkout. That’s how a single working directory behaves, not branch state leaking between sessions.

For true per-session isolation when you’re running work in parallel, give each task its own worktree:

  1. In the Agents Window, start or move parallel and background tasks into a worktree. Each gets its own isolated checkout and branch, and your main checkout stays untouched.
  2. In the IDE, run a chat with /worktree for a single isolated checkout, then /apply-worktree to bring changes back.
  3. For a subagent fleet, ask the parent agent to create a worktree per subagent so each runs on its own branch. Cloud subagents are another option, since they run on their own VM and branch.

Docs: Worktrees and multi-agent coding.

If you set things up in isolated worktrees and still see one worktree’s branch bleed into another, that’s a genuine bug. Grab a quick screen recording of that case and we’ll dig in.