Worktree branch created from wrong base branch and stale commit

Resolved 💬 2 comments Opened Apr 8, 2026 by vlastimilvajnorak Closed May 26, 2026

Describe the bug

When Claude Code creates a worktree, it does not use the repository's configured default branch from GitHub, and it does not fetch the latest state before branching. The result is a worktree that starts from the wrong branch and is missing recent commits.

Steps to reproduce

  1. Have a repository where the default branch in GitHub is set to develop (not main)
  2. Let Claude Code create a worktree (e.g. via an agentic task)
  3. Observe the base branch and commit the worktree was created from

Expected behavior

  • Claude Code reads the repository's GitHub default branch (e.g. via git remote show origin or GitHub API) and uses it as the base
  • Claude Code runs git fetch origin before creating the worktree branch, so the base is always up to date

Actual behavior

  • Worktree was branched from main instead of the actual GitHub default branch (develop)
  • Worktree was ~2 commits behind the actual tip of the intended base branch

Environment

  • OS: Windows 11
  • Shell: bash (Git Bash)
  • Claude Code version: latest

🤖 Reported via Claude Code CLI

View original on GitHub ↗

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