Main branch detection picks `master` over `develop` even when `origin/HEAD` points to `develop`

Resolved 💬 2 comments Opened Mar 12, 2026 by frizar Closed Apr 9, 2026

Description

The gitStatus metadata injected at session start reports Main branch (you will usually use this for PRs): master even though origin/HEAD points to develop, which is the repo's actual default branch on GitHub.

This causes PRs to be created against the wrong base branch when the user doesn't explicitly specify one.

Steps to reproduce

  1. Have a repo where the GitHub default branch is develop
  2. The repo also has a master branch (legacy, not default)
  3. Verify: git symbolic-ref refs/remotes/origin/HEADrefs/remotes/origin/develop
  4. Start a Claude Code session
  5. Observe the gitStatus says Main branch: master

Expected behavior

Claude Code should respect origin/HEAD (which reflects the GitHub default branch) rather than preferring a branch named master by heuristic.

Environment

  • macOS (Darwin 25.2.0)
  • Claude Code (latest as of 2026-03-12)

View original on GitHub ↗

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