[BUG] mainBranch setting in .claude/settings.json is ignored in git worktrees — gitStatus always shows 'main'

Resolved 💬 3 comments Opened Mar 1, 2026 by aliaksandr-master Closed Mar 5, 2026

Description

When working in a Claude Code session that starts inside a git worktree, the mainBranch setting is not respected. The gitStatus block injected at the start of the session always shows main as the base branch regardless of what is configured.

Environment

  • Claude Code (latest)
  • macOS Darwin 25.3.0
  • git worktree workflow (worktrees created by Claude Code under .claude/worktrees/<name>)

Configuration

.claude/settings.json in the project root:

{
  "mainBranch": "dev"
}

.claude/settings.json inside the worktree (.claude/worktrees/<name>/.claude/settings.json) — same content:

{
  "mainBranch": "dev"
}

Observed behavior

The gitStatus block injected into the system prompt at session start reads:

Main branch (you will usually use this for PRs): main

Expected behavior

Should read:

Main branch (you will usually use this for PRs): dev

Steps to reproduce

  1. Open a project where the default branch is not main (e.g. dev)
  2. Set "mainBranch": "dev" in .claude/settings.json
  3. Start a Claude Code session via a git worktree (e.g. claude/my-worktree)
  4. Observe the gitStatus block — mainBranch still shows main

Notes

  • The bug appears consistently across multiple sessions
  • Outside of worktrees the setting may work correctly (not verified)
  • The worktree's .git file correctly points to the parent repo: gitdir: /path/to/repo/.git/worktrees/<name>
  • remotes/origin/HEAD -> origin/dev is set correctly on the remote

View original on GitHub ↗

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