claude-code - 💡(How to fix) Fix `/resume` cannot surface sessions launched from a bare+worktrees root [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51900Fetched 2026-04-23 07:41:55
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×1renamed ×1

When claude is launched from the root of a "bare + sibling worktrees" git layout — where the launch dir contains .bare/ and a .git file (gitdir: ./.bare) but is itself not a registered worktree — session JSONLs are written correctly, but /resume cannot list them under any scope toggle except Ctrl+A (all projects).

Root Cause

  1. cd myrepo && claude → runs fine; jsonls written to ~/.claude/projects/-path-to-myrepo/ with cwd: /path/to/myrepo and gitBranch: main.
  2. Accumulate N sessions this way.
  3. /resume from the same dir → empty list. Header shows scope .bare · myrepo.
  4. Ctrl+B (current branch): still empty — filter is branch .bare, but stored sessions have gitBranch: main.
  5. Ctrl+W (all worktrees): shows only sessions stored under registered worktrees (main/, docs/) — never the sessions at the root project dir, because git worktree list has no entry for the root.
  6. Ctrl+A (all projects): finally shows them, mixed in with every other project globally.

Fix Action

Fix / Workaround

Workarounds tried

Code Example

myrepo/               # launch dir: contains `.git` file pointing at .bare/, NOT a registered worktree
├── .bare/            # the gitdir (bare repo)
├── main/             # registered worktree (branch: main)
└── docs/             # registered worktree

---

/path/to/myrepo/.bare  (bare)
/path/to/myrepo/main   abc1234 [main]
RAW_BUFFERClick to expand / collapse

Summary

When claude is launched from the root of a "bare + sibling worktrees" git layout — where the launch dir contains .bare/ and a .git file (gitdir: ./.bare) but is itself not a registered worktree — session JSONLs are written correctly, but /resume cannot list them under any scope toggle except Ctrl+A (all projects).

Repro

Layout:

myrepo/               # launch dir: contains `.git` file pointing at .bare/, NOT a registered worktree
├── .bare/            # the gitdir (bare repo)
├── main/             # registered worktree (branch: main)
└── docs/             # registered worktree

git worktree list from the root:

/path/to/myrepo/.bare  (bare)
/path/to/myrepo/main   abc1234 [main]

git rev-parse --show-toplevel from the root: fatal: this operation must be run in a work tree.

  1. cd myrepo && claude → runs fine; jsonls written to ~/.claude/projects/-path-to-myrepo/ with cwd: /path/to/myrepo and gitBranch: main.
  2. Accumulate N sessions this way.
  3. /resume from the same dir → empty list. Header shows scope .bare · myrepo.
  4. Ctrl+B (current branch): still empty — filter is branch .bare, but stored sessions have gitBranch: main.
  5. Ctrl+W (all worktrees): shows only sessions stored under registered worktrees (main/, docs/) — never the sessions at the root project dir, because git worktree list has no entry for the root.
  6. Ctrl+A (all projects): finally shows them, mixed in with every other project globally.

Expected

Either:

  • Default scope should include the launch dir's own project dir under ~/.claude/projects/…, even when the launch dir isn't a registered worktree, or
  • A settings key (e.g. resume.defaultScope: "project" | "worktrees" | "all") to pin the default.

Actual

Sessions are reachable only via Ctrl+A (noisy) or claude -c / --resume <id> (bypass the picker). From the user's POV: "my history disappeared" when launching from the root.

Workarounds tried

  • Ctrl+W — only walks git worktree list, root isn't listed, so misses the sessions.
  • Moving jsonls into a sibling worktree's project dir — works until next new session is written.
  • Registering the root as a worktree (git worktree add --force . <branch>) — changes repo layout and pollutes the root dir.

Environment

  • Claude Code 2.1.117
  • macOS 26.4 (arm64)
  • git worktree layout: bare at ./.bare, siblings for each branch

extent analysis

TL;DR

The issue can be mitigated by using the Ctrl+A shortcut to view all projects or by registering the root as a worktree, but a more permanent solution may involve modifying the default scope or adding a settings key.

Guidance

  • The problem seems to stem from the fact that the launch directory is not a registered worktree, causing the /resume command to not list sessions under any scope toggle except Ctrl+A.
  • To verify the issue, try running git worktree list from the root directory and check if the root directory is listed.
  • A potential workaround is to use the Ctrl+A shortcut to view all projects, but this may be noisy.
  • Another possible solution is to register the root as a worktree using git worktree add --force . <branch>, but this may change the repo layout and pollute the root dir.

Example

No code snippet is provided as it is not clearly supported by the issue.

Notes

The issue seems to be specific to the "bare + sibling worktrees" git layout and the fact that the launch directory is not a registered worktree. The solution may involve modifying the default scope or adding a settings key to pin the default scope.

Recommendation

Apply workaround: Using the Ctrl+A shortcut to view all projects is a viable workaround, as it allows users to access their session history, albeit in a noisy manner. A more permanent solution would require modifying the default scope or adding a settings key, but this is not currently available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING