Worktree isolation breaks bare-repo worktree layouts by setting extensions.worktreeConfig
Bug Description
Claude Code's worktree isolation feature (isolation: "worktree") breaks existing worktrees in bare-repo layouts by setting extensions.worktreeConfig = true in the shared git config without updating existing worktrees.
Steps to Reproduce
- Set up a bare-repo worktree layout:
``bash``
git clone --bare git@github.com:org/repo.git repo/.bare
echo "gitdir: ./.bare" > repo/.git
git -C repo worktree add main
git -C repo worktree add feature/my-branch
- Use Claude Code in one of the worktrees
- Claude Code's plan mode (or agent with
isolation: "worktree") creates an isolated worktree under.claude/worktrees/<name>
- All existing worktrees (
main,feature/my-branch) break — git commands fail or behave as if the repo is bare
Root Cause
When creating the isolated worktree, Claude Code:
- Sets
extensions.worktreeConfig = truein the shared git config (.bare/config) - Writes
core.longpaths = trueto the new worktree'sconfig.worktreefile - Does not create
config.worktreefiles for existing worktrees
Once extensions.worktreeConfig = true is set, core.bare becomes a per-worktree setting. The shared config has core.bare = true (it's a bare repo). Existing worktrees that don't have a config.worktree with core.bare = false now inherit core.bare = true and break.
Additional Issues
core.longpathsis a Windows-only setting (enables paths > 260 chars). Setting it on macOS/Linux is unnecessary and should be skipped on non-Windows platforms.extensions.worktreeConfigis never set automatically by any git command — this is an explicit action by the Claude Code agent infrastructure.
Evidence
All three files modified at the same timestamp (Apr 7 17:50:05 2026):
.bare/config—extensions.worktreeConfig = trueadded.bare/worktrees/affectionate-borg/config.worktree—core.longpaths = true.bare/worktrees/affectionate-borg/HEAD— worktree creation
Existing worktrees (main, azure-iac) had no config.worktree files and broke immediately.
Expected Behavior
When creating an isolated worktree in a bare-repo layout, Claude Code should either:
- Not set
extensions.worktreeConfigif the only per-worktree config iscore.longpathson a non-Windows platform (skip the setting entirely) - If
extensions.worktreeConfigmust be set, createconfig.worktreefiles withcore.bare = falsefor all existing worktrees first
Environment
- Platform: macOS (Darwin 25.4.0, Apple Silicon)
- Git version: 2.49.0
- Claude Code model: claude-opus-4-6 (1M context)
- Repo layout: Bare repo with linked worktrees (
git clone --barepattern)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗