[BUG] Worktree branch picker dropdown caches stale remote branch list; new origin branches don't appear after git push + app restart
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code's "select branch for worktree spawn" dropdown shows a cached snapshot of remote branches that doesn't refresh when:
A new branch is pushed to origin via CLI (git push origin ...)
The Claude Code Windows app is fully closed and reopened
The parent repo on disk has been git fetch --all --prune'd so its git branch -r shows the new branch
The dropdown also fails to remove branches that have been deleted from origin (shows ghosts of long-merged-and-deleted branches) — confirming the cache isn't simply stale on the additive side.
This forces users into a workaround pattern (spawn from main, push to renamed branch in PR) that adds friction to every multi-PR project workflow.
What Should Happen?
One of:
A. Branch list re-fetches on every "New session" / branch picker open. Cache TTL ≤ session length.
B. Branch list re-fetches on app launch. Cache cleared on app close.
C. Explicit "Refresh branches" button next to / inside the picker dropdown.
Any of A/B/C unblocks the workflow. Today none are present.
Error Messages/Logs
Branch list appears to be cached in Electron Local Storage / IndexedDB and persisted across app restarts indefinitely. No user-facing trigger to force refresh has been found.
Steps to Reproduce
1. Have a project with an existing worktree open in Claude Code (e.g. parent at D:\aaas-pov\)
2. From any worktree or the parent, push a NEW branch to origin:
git push origin origin/main:refs/heads/feature/test-new-branch
3. Verify the branch exists on origin:
gh api repos/<owner>/<repo>/branches | jq '.[].name' | grep test-new-branch
→ feature/test-new-branch
4. Verify local git knows about it (after fetch):
git -C <parent-repo> fetch --all --prune
git -C <parent-repo> branch -r | grep test-new-branch
→ origin/feature/test-new-branch
5. In Claude Code, click "New session" → click the "main" / branch picker dropdown
Expected: feature/test-new-branch appears in the list
Actual: feature/test-new-branch does NOT appear, even after fully closing
and reopening the Claude Code app
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.121
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Bug report draft — Claude Code branch list cache stale
Target: github.com/anthropics/claude-code/issues/new
Drafted: 2026-05-03 in D60 PR-E session
Reporter: Jirachai Thiemsert (cray.j.thiemsert@gmail.com)
---
Suggested title
Worktree branch picker dropdown caches stale remote branch list; new origin branches don't appear after git push + app restart
Summary
Claude Code's "select branch for worktree spawn" dropdown shows a cached snapshot of remote branches that doesn't refresh when:
- A new branch is pushed to origin via CLI (
git push origin ...) - The Claude Code Windows app is fully closed and reopened
- The parent repo on disk has been
git fetch --all --prune'd so itsgit branch -rshows the new branch
The dropdown also fails to remove branches that have been deleted from origin (shows ghosts of long-merged-and-deleted branches) — confirming the cache isn't simply stale on the additive side.
This forces users into a workaround pattern (spawn from main, push to renamed branch in PR) that adds friction to every multi-PR project workflow.
Steps to reproduce
# 1. Have a project with an existing worktree open in Claude Code (e.g. parent at D:\aaas-pov\)
# 2. From any worktree or the parent, push a NEW branch to origin:
git push origin origin/main:refs/heads/feature/test-new-branch
# 3. Verify the branch exists on origin:
gh api repos/<owner>/<repo>/branches | jq '.[].name' | grep test-new-branch
# → feature/test-new-branch
# 4. Verify local git knows about it (after fetch):
git -C <parent-repo> fetch --all --prune
git -C <parent-repo> branch -r | grep test-new-branch
# → origin/feature/test-new-branch
# 5. In Claude Code, click "New session" → click the "main" / branch picker dropdown
# Expected: feature/test-new-branch appears in the list
# Actual: feature/test-new-branch does NOT appear, even after fully closing
# and reopening the Claude Code app
Additionally:
# 6. Delete a branch on origin:
git push origin --delete feature/old-merged-branch
# 7. fetch --prune:
git -C <parent-repo> fetch --prune
# → origin/feature/old-merged-branch is gone from local refs
# 8. In Claude Code dropdown:
# Expected: feature/old-merged-branch is gone
# Actual: feature/old-merged-branch is STILL listed (ghost branch)
Expected behaviour
One of:
- A. Branch list re-fetches on every "New session" / branch picker open. Cache TTL ≤ session length.
- B. Branch list re-fetches on app launch. Cache cleared on app close.
- C. Explicit "Refresh branches" button next to / inside the picker dropdown.
Any of A/B/C unblocks the workflow. Today none are present.
Actual behaviour
Branch list appears to be cached in Electron Local Storage / IndexedDB and persisted across app restarts indefinitely. No user-facing trigger to force refresh has been found.
Diagnostic evidence
Proof Claude Code is NOT reading from local git
Same project, same moment in time:
| Source | What it shows |
|---|---|
| git -C <parent-repo> branch -r \| grep d60 | origin/feature/d60-ontology-discovery-agent |
| gh api repos/<owner>/<repo>/branches \| jq '.[].name' \| grep d60 | feature/d60-ontology-discovery-agent, feature/d60-pr-f-live-verify |
| Claude Code dropdown | feature/d60-pr-d-discovery-agent (different name!) — and d60-pr-f-live-verify is missing |
The dropdown shows a branch name (feature/d60-pr-d-discovery-agent) that does not exist anywhere in current git refs nor on origin. The closest match is feature/d60-ontology-discovery-agent which the dropdown does not show. Implication: the cache was populated from an earlier state of the project (perhaps a renamed/deleted branch) and never reconciled.
Likely cache location
%APPDATA%\Claude\Local Storage\leveldb\ ← LevelDB blobs
%APPDATA%\Claude\IndexedDB\ ← per-origin databases
Standard Electron storage locations. Manual deletion would force re-fetch but risks losing login session, recent files, and other UI state.
Workaround currently in use
Spawn worktree from main (always present in dropdown) and rely on agent to push to the intended branch name in the PR commit:
# Inside the spawned worktree (Claude-named local branch)
git push -u origin claude/<spawn-id>:feature/<intended-name>
gh pr create --head feature/<intended-name> --base main ...
Works but adds confusion: the local working branch and the remote PR branch have different names, which surfaces in git status, in PR-comment templates, and in any automation that assumes branch-name parity.
Suggested fix
In priority order (by user value vs implementation cost):
- Add a "Refresh" / icon-button next to the branch picker that calls the GitHub API and replaces the cached list. ~10 LoC + 1 API call. Closes the bug for power users.
- Re-fetch branch list every time the picker opens (debounced to 1 fetch / 30s). Slightly more API traffic but no user training needed.
- Cache TTL = session length. Re-fetch on app launch. Reasonable middle ground.
- Show a "last fetched X minutes ago" timestamp in the dropdown so users can spot stale state without having to verify externally.
(1) and (2) are not mutually exclusive — both are valuable.
Environment
| Field | Value |
|---|---|
| Claude Code (Windows) | 2.1.121 |
| App data path | C:\Users\<user>\AppData\Roaming\Claude\claude-code\2.1.121\claude.exe |
| OS | Windows 11 (10.0.26200) |
| Shell | MINGW64_NT (Git Bash) + PowerShell 5.1 |
| Project structure | Git worktrees under <repo>\.claude\worktrees\<spawn-name>\ |
Impact
This affects every multi-PR project workflow where:
- The user works in feature branches following a
feature/<scope>-<id>-<description>convention - Branches are created from the CLI (not via the Claude Code UI)
- Sessions are scoped per-PR (auto-closes worktree on merge)
For our project (5 PRs across 7 days, all needing fresh worktrees on per-PR feature branches) this surfaced ~3 times during the week and required the workaround each time.
References
- Project workflow that surfaced this: github.com/CrayJThiemsert/aaas-pov D60 PR-E session, 2026-05-03
- Workaround captured in
.memory/learnings.md - Claude Code Windows app under
%APPDATA%\Claude\claude-code\2.1.121\
---
How to file
- Open https://github.com/anthropics/claude-code/issues/new
- Choose "Bug report" template (if available)
- Paste sections Summary through Environment above
- Add labels:
bug,windows,worktree,ui - Optional: attach the screenshot from this session showing the missing branch in the dropdown
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗