Worktree isolation breaks bare-repo worktree layouts by setting extensions.worktreeConfig

Resolved 💬 2 comments Opened Apr 8, 2026 by therickfactr Closed May 22, 2026

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

  1. 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
``

  1. Use Claude Code in one of the worktrees
  1. Claude Code's plan mode (or agent with isolation: "worktree") creates an isolated worktree under .claude/worktrees/<name>
  1. 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:

  1. Sets extensions.worktreeConfig = true in the shared git config (.bare/config)
  2. Writes core.longpaths = true to the new worktree's config.worktree file
  3. Does not create config.worktree files 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.longpaths is a Windows-only setting (enables paths > 260 chars). Setting it on macOS/Linux is unnecessary and should be skipped on non-Windows platforms.
  • extensions.worktreeConfig is 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/configextensions.worktreeConfig = true added
  • .bare/worktrees/affectionate-borg/config.worktreecore.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:

  1. Not set extensions.worktreeConfig if the only per-worktree config is core.longpaths on a non-Windows platform (skip the setting entirely)
  2. If extensions.worktreeConfig must be set, create config.worktree files with core.bare = false for 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 --bare pattern)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗