Stash Pop Conflict After Claude Edits — Fix (2026)
The Error
Auto-merging src/utils/helpers.ts
CONFLICT (content): Merge conflict in src/utils/helpers.ts
Stashed changes conflict with Claude Code's edits on lines 12-34
The stash was not dropped. Use 'git stash drop' after resolving.
This appears when you git stash pop and the stashed changes conflict with modifications Claude Code made while the changes were stashed.
The Fix
claude "Resolve the stash conflict in src/utils/helpers.ts — keep Claude's refactored version and integrate the stashed validation logic"
- Let Claude Code resolve the conflict by reading the conflict markers and merging both versions.
- Stage the resolved file:
git add src/utils/helpers.ts. - Drop the stash after confirming the resolution:
git stash drop.
Why This Happens
A common workflow is to stash uncommitted changes before asking Claude Code to work on the same files. When you pop the stash afterwards, Git tries to merge the stashed changes with Claude’s modifications. If both touched the same lines, the merge fails with conflict markers. Unlike a branch merge, the stash remains in the stash list until explicitly dropped after resolution.
If That Doesn’t Work
Keep Claude’s version and discard the stashed changes:
git checkout --theirs src/utils/helpers.ts
git add src/utils/helpers.ts
git stash drop
Keep the stashed version and discard Claude’s changes:
git checkout --ours src/utils/helpers.ts
git add src/utils/helpers.ts
git stash drop
Apply the stash to a new branch instead:
git stash branch stash-recovery
# Now resolve conflicts on the separate branch
Prevention
# CLAUDE.md rule
Before stashing, commit your work-in-progress to a WIP branch instead: 'git checkout -b wip && git commit -am "WIP"'. This avoids stash conflicts entirely. Never stash and then ask Claude to edit the same files.
Related Error Messages
This fix also applies if you see these related error messages:
fatal: not a git repositoryerror: failed to push some refsfatal: refusing to merge unrelated historiesCONFLICT (content): Merge conflict in fileAutomatic merge failed; fix conflicts and then commit
Frequently Asked Questions
Why does Claude Code require git?
Claude Code uses git for several core operations: tracking file changes, creating commits, reading blame information, searching history with git log, and managing branches. Without git, these operations fail and Claude Code falls back to less efficient alternatives.
Can Claude Code work in a non-git directory?
Yes, but with reduced functionality. File search and editing work normally, but version control operations (commit, diff, blame) are unavailable. Claude Code displays a warning when opened in a directory without git initialization.
How do I prevent Claude Code from making unwanted git operations?
Add rules to your CLAUDE.md: Do not create commits automatically. Do not run git push. Always ask before any git operation that modifies history. Claude Code respects these constraints and asks for confirmation before proceeding.
Can Claude Code resolve merge conflicts?
Yes. Claude Code can read files with conflict markers and intelligently resolve them by understanding the intent of both changes. Ask it to ‘resolve the merge conflict in file.ts’ and it will read the file, analyze both sides, and produce a clean resolution.
Related Guides
Try it: Paste your error into our Error Diagnostic for an instant fix.
- Terminal Emulator Rendering Artifacts — Fix (2026)
- How to Use Thirdweb SDK Workflow (2026)
- Python Virtualenv Not Activated — Fix (2026)
- Claude Code Offline Mode Setup (2026)
Implementation Details
When working with this in Claude Code, pay attention to these practical details:
Project configuration. Add specific instructions to your CLAUDE.md file describing how your project handles this area. Include file paths, naming conventions, and any patterns that differ from common defaults. Claude Code reads CLAUDE.md at the start of every session and uses it to guide all operations.
Testing the setup. After configuration, verify everything works by running a simple test task. Ask Claude Code to perform a read-only operation first (like listing files or reading a config) before moving to write operations. This confirms that permissions, paths, and tools are all correctly configured.
Monitoring and iteration. Track your results over several sessions. If Claude Code consistently makes the same mistake, the fix is usually a more specific CLAUDE.md instruction. If it makes different mistakes each time, the issue is likely in the project setup or toolchain configuration.
Troubleshooting Checklist
When something does not work as expected, check these items in order:
- CLAUDE.md exists at the project root — run
ls -la CLAUDE.mdto verify - Node.js version is 18+ — run
node --versionto check - API key is set — run
echo $ANTHROPIC_API_KEY | head -c 10to verify (shows first 10 characters only) - Disk space is available — run
df -h .to check - Network can reach the API — run
curl -s -o /dev/null -w "%{http_code}" https://api.anthropic.com(should return 401 without auth, meaning the server is reachable) - No conflicting processes — run
ps aux | grep claude | grep -v grepto check for stale sessions