claude-code - 💡(How to fix) Fix [BUG] 3+ hours lost at the start of a session just recovering from what the previous session's cold start broke. [1 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#54925Fetched 2026-05-01 05:50:49
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1unlabeled ×1

Error Message

Claude should check git log --all --oneline and compare branch heads before making any commits, and warn the user if the current branch appears to be significantly behind other branches in the same repo.

Error Messages/Logs

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?

Expected behavior: Claude should check git log --all --oneline and compare branch heads before making any commits, and warn the user if the current branch appears to be significantly behind other branches in the same repo.

Actual behavior: Claude operates confidently on the current branch with no awareness that other branches exist with more recent work. Infra changes (deploy workflow, Docker config, SSL config) get committed and deployed, breaking the live site. Feature code from 107 commits across 3 weeks was inaccessible until manually merged.

Impact: 3+ hours of recovery time. Live site was down for part of that time. No data was permanently lost (git history preserved everything) but it required deep git forensics to identify and recover.

What Should Happen?

At session start, run git log --all --oneline and surface a warning if the current branch is significantly behind another branch, asking the user which branch to work from before proceeding.

Error Messages/Logs

Steps to Reproduce

Title: New session starts from wrong branch base, silently overwrites months of feature work

Steps to reproduce:

Have an active project with multiple Claude Code sessions over weeks, each on a different claude/... branch Start a new Claude Code session Ask Claude to rename the current branch or do any simple task Claude reads CLAUDE.md (if it exists) but has no awareness of which branch in the repo has the most recent feature work Claude begins making and committing changes on a branch that is 100+ commits behind the most feature-complete branch Changes get pushed and deployed — overwriting the live server with months-old code

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

Claude Code 2.1.123

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be mitigated by modifying Claude Code to run git log --all --oneline at session start and warning the user if the current branch is significantly behind another branch.

Guidance

  • Review the Claude Code version 2.1.123 documentation to see if there are any configuration options or flags that can be used to enable the desired behavior.
  • Consider adding a custom script to run at the start of each Claude Code session that checks the git log and warns the user if the current branch is out of date.
  • Investigate the differences between the current version and the previous version that worked as expected to identify potential changes that may have introduced the issue.
  • Check the Anthropic API documentation to see if there are any API calls or endpoints that can be used to retrieve information about the repository branches and their commit history.

Example

git log --all --oneline --decorate --simplify-by-decoration

This command can be used to retrieve a list of all commits across all branches in the repository, which can be used to determine if the current branch is significantly behind another branch.

Notes

The issue may be specific to the Claude Code version 2.1.123 and the Anthropic API platform, and may not be reproducible on other versions or platforms.

Recommendation

Apply a workaround by adding a custom script to run at the start of each Claude Code session that checks the git log and warns the user if the current branch is out of date. This is because the issue is a regression and the previous version worked as expected, but the current version does not have the desired behavior.

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