claude-code - 💡(How to fix) Fix worktree.baseRef: "head" creates worktree from default branch (main) instead of current branch

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When worktree.baseRef is set to "head" in .claude/settings.local.json, new worktrees are created from the repository's default branch (main) instead of the user's current working branch.

Root Cause

When worktree.baseRef is set to "head" in .claude/settings.local.json, new worktrees are created from the repository's default branch (main) instead of the user's current working branch.

Code Example

git log --oneline -3 claude/elated-darwin-16dfbc
# 27be31e chore(prod): sync from develop   ← identical to main tip

git log --oneline -3 main
# 27be31e chore(prod): sync from develop   ← same commit

---

"worktree": {
  "baseRef": "head"
}
RAW_BUFFERClick to expand / collapse

Summary

When worktree.baseRef is set to "head" in .claude/settings.local.json, new worktrees are created from the repository's default branch (main) instead of the user's current working branch.

Expected behavior

Per the schema description:

'head' branches from your current local HEAD so unpushed commits and feature-branch state are present.

When working on branch develop, a new worktree should be created from develop's HEAD.

Actual behavior

The worktree is created from main regardless of the current branch. Verified by comparing the worktree branch tip with main:

git log --oneline -3 claude/elated-darwin-16dfbc
# 27be31e chore(prod): sync from develop   ← identical to main tip

git log --oneline -3 main
# 27be31e chore(prod): sync from develop   ← same commit

The merge-base of the new worktree branch with develop was an older commit, not the current HEAD of develop.

Steps to reproduce

  1. Set up a repo with main and develop branches (develop is ahead of main)
  2. Set "worktree": { "baseRef": "head" } in .claude/settings.local.json
  3. Check out develop
  4. Enable the worktree checkbox in the Claude Code UI
  5. Observe that the new claude/<name> branch starts from main's HEAD, not develop's HEAD

Configuration

"worktree": {
  "baseRef": "head"
}

Additional context

  • Only two values are accepted by the schema: "fresh" and "head"
  • Both values appear to result in worktrees based on main (the default branch)
  • "fresh" is described as branching from origin/<default-branch> — so the difference between "fresh" and "head" is unclear if both point to main
  • No global settings override was present (~/.claude/settings.json had no worktree key)

Suggestion

Either fix "head" to use the actual current branch's HEAD, or add a third option (e.g. "branch") that explicitly uses the current working branch.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Per the schema description:

'head' branches from your current local HEAD so unpushed commits and feature-branch state are present.

When working on branch develop, a new worktree should be created from develop's HEAD.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING