[BUG] origin remote URL corruption via GIT_COMMON_DIR + rbs/ruby-lsp in devcontainer
Summary
The repository's origin remote was corrupted: the URL changed fromgit@github.com:org/myrepo.git tohttps://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/Time | Event |
|---|---|
| 2026-04-17 ~16:46 UTC | Claude Code created branch worktree-user+test from origin/main via its isolation: "worktree" feature |
| 2026-04-17 ~17:03 UTC | Commit on worktree-user+test: "dev container compatibility for git worktree" |
| 2026-04-20 12:01:07 UTC | User 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 UTC | FETCH_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 withremote = 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+testis 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
EnterWorktreetool is available in Claude Code sessions and is part of the
isolation: "worktree" implementation.
- The
promisor = trueandpartialclonefilter = blob:nonesettings are
characteristics of a partial clone — a technique Claude Code likely uses to
create lightweight worktrees.
Probable sequence
- 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.
- April 20, 12:01: The user manually created the
testworktree.
git worktree add itself does not modify remotes.
- 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_collectionrepository,
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 pushfailed withremote: Permission to ruby/gem_rbs_collection.git denied to username.git fetchwas 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 = git@github.com: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(setsextensions.worktreeConfig), confirming the feature writes to the shared config as a side effect. - anthropics/claude-code#47266 — concurrent worktree creation causes
.git/configlock collisions, further evidence that the feature performs direct writes to.git/config.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗