claude-code - 💡(How to fix) Fix [BUG] New session branch is created from first repository commit instead of selected branch HEAD [2 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#55591Fetched 2026-05-03 04:49:27
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×5commented ×2

Error Message

Error Messages/Logs

Code Example

As show below, I've selected "main" branch (that have almost 200 commits) and started a new session....my first prompt was:

Could you run for me:
git log --oneline


The result:

<img width="800" height="221" alt="Image" src="https://github.com/user-attachments/assets/20594f76-106b-45f9-9cf1-ba8707b64e04" />

<img width="495" height="308" alt="Image" src="https://github.com/user-attachments/assets/e0ce95d3-8ef3-4082-be7e-c9bb152ab487" />


After manually running git rebase origin/main, the branch correctly moved to the current HEAD and all outdated references disappeared

This have been happening both in Cloud Code desktop for mac and claude.ai/code.
I'm using Claude Code for Mac 1.5354.0 as show below:

<img width="321" height="361" alt="Image" src="https://github.com/user-attachments/assets/714e4c11-9dfe-4299-a20f-06aed842d387" />
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When starting a new Claude Code session and selecting an existing branch (e.g. main), the working branch created for the session is based on the repository's very first commit rather than the current HEAD of the selected branch. This means the session starts with a completely outdated codebase — in my case, over 150 commits behind — causing Claude to reference removed dependencies, outdated architecture, and deleted code as if they were still present.

What Should Happen?

New sessions should start from updated branch, getting all the stuff that this branch actually have in it.

Error Messages/Logs

As show below, I've selected "main" branch (that have almost 200 commits) and started a new session....my first prompt was:

Could you run for me:
git log --oneline


The result:

<img width="800" height="221" alt="Image" src="https://github.com/user-attachments/assets/20594f76-106b-45f9-9cf1-ba8707b64e04" />

<img width="495" height="308" alt="Image" src="https://github.com/user-attachments/assets/e0ce95d3-8ef3-4082-be7e-c9bb152ab487" />


After manually running git rebase origin/main, the branch correctly moved to the current HEAD and all outdated references disappeared

This have been happening both in Cloud Code desktop for mac and claude.ai/code.
I'm using Claude Code for Mac 1.5354.0 as show below:

<img width="321" height="361" alt="Image" src="https://github.com/user-attachments/assets/714e4c11-9dfe-4299-a20f-06aed842d387" />

Steps to Reproduce

  1. Go to "new session" and select a repo and branch with a lot of commits
  2. Start a session and check if it's updated based on it's branch actual state

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Claude 1.5354.0 (9a9e3d) 2026-04-29T01:14:34.000Z

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

The issue can likely be resolved by ensuring that the working branch created for the session is updated to the current HEAD of the selected branch, possibly by modifying the git commands used to initialize the session.

Guidance

  • Verify that the git log --oneline command is correctly showing the commit history for the selected branch, and check if the working branch is correctly set to the current HEAD of the selected branch.
  • Investigate the git commands used to initialize the session and consider modifying them to include a git pull or git rebase command to update the working branch to the current HEAD of the selected branch.
  • Check the documentation for Claude Code to see if there are any configuration options or settings that can be adjusted to control how the working branch is initialized.
  • Test the session with a different branch or repository to see if the issue is specific to the current setup.

Example

No code snippet is provided as the issue does not explicitly mention any specific code that needs to be modified.

Notes

The issue may be related to how Claude Code handles git branches and commits, and further investigation into the git commands used by Claude Code may be necessary to resolve the issue.

Recommendation

Apply workaround: Modify the git commands used to initialize the session to include a git pull or git rebase command to update the working branch to the current HEAD of the selected branch, as manually running git rebase origin/main resolved the issue in the reported case.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] New session branch is created from first repository commit instead of selected branch HEAD [2 comments, 2 participants]