claude-code - 💡(How to fix) Fix [BUG] isolation: "worktree" corrupts origin remote URL and injects partial clone settings into .git/config

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…

The repository's origin remote was corrupted: the URL changed from [email protected]:org/myrepo.git to https://github.com/ruby/gem_rbs_collection.git, and partial clone settings (promisor = true, partialclonefilter = blob:none) were injected along with duplicate fetch entries. As a result, git push failed with "Permission denied" and git fetch was pulling branches from an unrelated repository.


Root Cause

Root cause (hypothesis)

Fix Action

Fix

Restore [remote "origin"] in .git/config:

[remote "origin"]
    url = [email protected]:org/myrepo.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Code Example

[remote "origin"]
    url = https://github.com/ruby/gem_rbs_collection.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    promisor = true
    partialclonefilter = blob:none
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*

---

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
    hooksPath = /Users/user/projects/myrepo/.git/hooks
[remote "origin"]
    url = https://github.com/ruby/gem_rbs_collection.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    promisor = true
    partialclonefilter = blob:none
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
...
[branch "worktree-user+test"]
    remote = origin
    merge = refs/heads/main

---

[remote "origin"]
    url = [email protected]:org/myrepo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
RAW_BUFFERClick to expand / collapse

Summary

The repository's origin remote was corrupted: the URL changed from [email protected]:org/myrepo.git to https://github.com/ruby/gem_rbs_collection.git, and partial clone settings (promisor = true, partialclonefilter = blob:none) were injected along with duplicate fetch entries. As a result, git push failed with "Permission denied" and git fetch was pulling branches from an unrelated repository.


Timeline

Date/TimeEvent
2026-04-17 ~16:46 UTCClaude Code created branch worktree-user+test from origin/main via its isolation: "worktree" feature
2026-04-17 ~17:03 UTCCommit on worktree-user+test: "dev container compatibility for git worktree"
2026-04-20 12:01:07 UTCUser manually created worktree test: git worktree add -b test ../.claude/worktrees/test user/my-feature
2026-04-20 12:09:31 UTC.git/config modified: origin URL replaced, partial clone config injected, refspecs duplicated
2026-04-20 12:10:09 UTCFETCH_HEAD updated with branches from ruby/gem_rbs_collection

Evidence

Resulting .git/config remote section:

[remote "origin"]
    url = https://github.com/ruby/gem_rbs_collection.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    promisor = true
    partialclonefilter = blob:none
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*

The config also contains a [branch "worktree-user+test"] entry with remote = origin and merge = refs/heads/main, auto-generated by Claude Code.

Full corrupted .git/config at time of detection:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
    hooksPath = /Users/user/projects/myrepo/.git/hooks
[remote "origin"]
    url = https://github.com/ruby/gem_rbs_collection.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    promisor = true
    partialclonefilter = blob:none
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/heads/*:refs/remotes/origin/*
...
[branch "worktree-user+test"]
    remote = origin
    merge = refs/heads/main

Root cause (hypothesis)

Evidence strongly points to Claude Code's isolation: "worktree" feature as the origin of the corruption. A git bug cannot be ruled out entirely, but is considered unlikely.

Evidence pointing to Claude Code

  • The branch worktree-user+test is clearly auto-generated — the user created -b test, not that name. It was created on April 17 from origin/main and has a commit authored by Claude Code.
  • The EnterWorktree tool is available in Claude Code sessions and is part of the isolation: "worktree" implementation.
  • The promisor = true and partialclonefilter = blob:none settings are characteristics of a partial clone — a technique Claude Code likely uses to create lightweight worktrees.

Probable sequence

  1. April 17: Claude Code ran an agent with isolation: "worktree", which invoked EnterWorktree. As part of its fetch mechanism, it configured origin with the wrong URL (gem_rbs_collection) and partial clone parameters, and created the worktree-user+test branch.

  2. April 20, 12:01: The user manually created the test worktree. git worktree add itself does not modify remotes.

  3. April 20, 12:09–12:10: A subsequent operation (possibly Claude Code re-invoking EnterWorktree, a fetch triggered by a devcontainer init script, or an IDE running git operations when opening the devcontainer) ran git fetch origin against the already-corrupted remote, updating FETCH_HEAD with gem_rbs_collection branches and consolidating the corruption in the config.

Why gem_rbs_collection

Unknown. Possible causes:

  • Bug in Claude Code when resolving the remote URL during worktree creation.
  • Confusion between the project remote and the gem_rbs_collection repository, which is a Ruby RBS type definitions collection — a dev dependency of the project's Ruby stack.

Ruled out: git bug

git worktree add is a local operation that does not modify remotes. All repository hooks are .sample files (inactive). git 2.50.1 (Apple Git-155) has no known bugs related to this operation.


Impact

  • git push failed with remote: Permission to ruby/gem_rbs_collection.git denied to username.
  • git fetch was pulling branches from an unrelated external repository.
  • No commits or project data were lost (local history was not affected).

Fix

Restore [remote "origin"] in .git/config:

[remote "origin"]
    url = [email protected]:org/myrepo.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Environment

  • OS: macOS Darwin 25.4.0
  • git: 2.50.1 (Apple Git-155)
  • Claude Code: CLI, model claude-sonnet-4-6
  • Project structure: monorepo with git worktrees stored under .claude/worktrees/
  • Active hooks: none (all .sample)

Related issues

  • anthropics/claude-code#45201 — isolation: "worktree" also modifies .git/config (sets extensions.worktreeConfig), confirming the feature writes to the shared config as a side effect.
  • anthropics/claude-code#47266 — concurrent worktree creation causes .git/config lock collisions, further evidence that the feature performs direct writes to .git/config.

extent analysis

TL;DR

The most likely fix is to manually restore the corrupted [remote "origin"] section in the .git/config file to its original state.

Guidance

  1. Verify the corruption: Check the .git/config file for the corrupted [remote "origin"] section, which should have an incorrect URL and duplicate fetch entries.
  2. Restore the original remote settings: Update the [remote "origin"] section to use the correct URL ([email protected]:org/myrepo.git) and remove the duplicate fetch entries, as well as the promisor and partialclonefilter settings.
  3. Test git operations: After restoring the remote settings, test git push and git fetch to ensure they are working correctly and not pulling from the unrelated repository.
  4. Investigate Claude Code's isolation: "worktree" feature: To prevent similar issues in the future, investigate how Claude Code's feature is modifying the .git/config file and consider reporting the issue to the Claude Code developers.

Example

The corrected [remote "origin"] section in the .git/config file should look like this:

[remote "origin"]
    url = [email protected]:org/myrepo.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Notes

The root cause of the issue is likely related to Claude Code's isolation: "worktree" feature, which is modifying the .git/config file. However, without more information about the feature's implementation, it's difficult to provide a more specific solution.

Recommendation

Apply the workaround by manually restoring the corrupted [remote "origin"] section in the .git/config file, as this is the most straightforward way to resolve the issue. It's also recommended to investigate the issue with Claude Code's developers to prevent similar problems in the future.

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

claude-code - 💡(How to fix) Fix [BUG] isolation: "worktree" corrupts origin remote URL and injects partial clone settings into .git/config