[BUG] `--resume` incorrectly reports no sessions when project is a bare repo
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 --resume returns "No conversations found to resume" even though session .jsonl files exist correctly in ~/.claude/projects/<encoded-cwd>/.
This happens when the working directory's git repository uses a bare repo setup (i.e. the git directory lives at a separate path rather than .git inside the working tree).
What Should Happen?
Previous sessions for the current working directory should be listed and resumable.
Error Messages/Logs
When running `claude --resume` from the directory of a bare repo:
No conversations found to resume.
Press Ctrl+C to exit and start a new conversation.
Debug log after running `DEBUG=1 claude --resume`:
/resume: loading sessions for cwd=/path/to/working-tree, worktrees=[/path/to/bare-repo.git, ...]
/resume: found 0 session files on disk
Steps to Reproduce
- Initialize a bare git repo for a working directory (git dir lives at a separate path specified by a
.git_file_ in the working directory, not the typical.git/directory) - Open Claude Code from the same directory and have a conversation
- Exit and run
claude --resumefrom the same location - Observe "No conversations found to resume" even though sessions exist in
~/.claude/projects/
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.71 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
Root cause
The root cause seems to be related to how claude --resume resolves the project path via git worktree list --porcelain:
With a bare repo, this always returns at least two entries: the bare repo path and the working tree. When worktrees.length > 1, the session search function switches to a prefix-matching mode: it encodes each worktree path and searches ~/.claude/projects/ for directories whose names match those prefixes.
The bug: the cwd is never included in the worktrees list, so the session directory — correctly encoded from the cwd — is never searched. Sessions are stored correctly but never found.
Workaround
This workaround is pretty tedious, but seems to work:
Create a real directory in ~/.claude/projects/ named after the encoded bare repo path, populated with _hard links_ to the session files. (Symlinks don't work — the code uses readdirSync with withFileTypes (lstat semantics), so symlinks don't satisfy the isDirectory() / isFile() checks.)
# Encode your paths: replace all non-alphanumeric characters with -. For example:
REAL="$HOME/.claude/projects/-Users-you-your-working-tree-path"
ALIAS="$HOME/.claude/projects/-Users-you-path-to-bare-repo-reponame-git"
mkdir "$ALIAS"
for f in "$REAL"/*.jsonl; do
ln "$f" "$ALIAS/$(basename "$f")"
done
_Note: new sessions won't appear in the alias directory automatically, so this needs to be re-run periodically._
Possibly related
This might be the same underlying issue as #19995 and #27676, but in this case it's triggered by bare repo setup rather than active worktrees or submodule repos.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗