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
- Have a repository where the default branch in GitHub is set to
develop(notmain) - Let Claude Code create a worktree (e.g. via an agentic task)
- 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 originor GitHub API) and uses it as the base - Claude Code runs
git fetch originbefore creating the worktree branch, so the base is always up to date
Actual behavior
- Worktree was branched from
maininstead 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
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗