[BUG] Cloud web sessions reuse repo volume — local branches diverge from remote after history rewrite

Resolved 💬 2 comments Opened Apr 6, 2026 by kno-raziel Closed May 16, 2026

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 main in 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

  1. Create a repo with commit history on main and start a Claude Code web session (repo is cloned)
  2. Outside the session, rewrite main with an orphan branch and force push (e.g., git checkout --orphan new-main && git add -A && git commit -m "initial commit" && git push --force)
  3. Start a new Claude Code web session on the same repo
  4. Run git log --oneline main | wc -l — observe it still has the old commit count
  5. Run git log --oneline origin/main | wc -l — observe it has the new (correct) count
  6. 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 main rewritten via orphan branch on April 4, 2026
  • The .git/shallow file 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 when origin/main still 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, and git blame results

View original on GitHub ↗

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