[BUG] master is incorrectly assumed as main branch name instead of reading from repo
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet (at least it not obviously in the search results for open issues including "master")
- [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 main branch is assumed to be named master in the session context that is provided to the model, regardless of what the repository's actual default branch is called, leading to incorrect suggestions (e.g. git checkout master).
What Should Happen?
Expected behavior: Any work steps involving the repo's main branch should work out of the box using the actually correct default branch's name. It should be read from the repo initially, and probably stored in MEMORY.md
Steps to Reproduce
- Have a git repository whose default branch is not master (e.g. named development)
- Open a new Claude Code session in that repository
- Ask Claude something like "what is the main branch of this repo?" or attempt a branch operation that references
the main branch
- Observe that Claude refers to master instead of the actual default branch name
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Claude Code Version
2.1.126
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
Why this matters beyond correctness: Hardcoding master as an assumed default also reflects an outdated convention. The industry has broadly moved away from this term due to its association with the master/slave metaphor, with GitHub, GitLab, and others defaulting to main since 2020. Baking master into the tooling as an assumption implicitly treats it as the norm, which is worth reconsidering regardless of the correctness issue.
(Generated by Claude ;) )
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗