[BUG] Cloud web sessions reuse repo volume — local branches diverge from remote after history rewrite
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?
The documentation states: "Isolated virtual machines: Each session runs in an isolated, Anthropic-managed VM". However, new cloud sessions inherit the git repository state from previous sessions because the repo volume persists between container recreations.
When the remote history is rewritten (orphan branch, force push, rebase), new sessions start with a stale local main that has no shared ancestry with origin/main.
- GitHub
main: 3 commits (orphan created April 4) - Local
mainin new session: 85 commits (pre-orphan history) git merge-base --is-ancestor origin/main main→ exit 1 (no shared ancestry)
Timestamps confirm the container is new (April 5) but .git/objects/ was created April 2 — the repo volume persisted.
What Should Happen?
A new session should have local branches that match the remote. After fetching, if main has diverged from origin/main (especially with no shared ancestry), the local branch should be reset to match the remote.
Error Messages/Logs
$ git log --oneline origin/main | wc -l
3
$ git log --oneline main | wc -l
85
$ git merge-base --is-ancestor origin/main main
exit: 1 # No shared ancestry
$ stat /home/user/<my-repo>/.git/objects/ | grep Birth
Birth: 2026-04-02 19:53:26 # Repo cloned 3 days ago
$ stat / | grep Birth
Birth: 2026-04-05 # Container is new
$ cat .git/shallow
70b37c5... # Root of pre-orphan history
Steps to Reproduce
- Create a repo with commit history on
mainand start a Claude Code web session (repo is cloned) - Outside the session, rewrite
mainwith an orphan branch and force push (e.g.,git checkout --orphan new-main && git add -A && git commit -m "initial commit" && git push --force) - Start a new Claude Code web session on the same repo
- Run
git log --oneline main | wc -l— observe it still has the old commit count - Run
git log --oneline origin/main | wc -l— observe it has the new (correct) count - Run
git merge-base --is-ancestor origin/main main— exit code 1, no shared ancestry
Root cause: The container is recreated per session, but the cloned repo directory (/home/user/<repo>) is mounted from a persistent volume. On session start, git fetch --depth 50 updates origin/main, but the local main branch is never reset to match.
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
Claude Code on the web (cloud session) — exact CLI version not checked
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Non-interactive/CI environment
Additional Information
- Confirmed in two independent new sessions on April 5, 2026, both showing the same stale local
main - The repo had
mainrewritten via orphan branch on April 4, 2026 - The
.git/shallowfile points to the root of the old history, not the current remote - Reflog shows only
main@{0}: branch: Created from refs/remotes/origin/main— created whenorigin/mainstill pointed to the old history - Impact: agents analyzing the repo see a local history that doesn't exist on GitHub, leading to misleading
git log,git diff, andgit blameresults
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗