Fix: Git Merge Conflict Loop
Error Message:
"Conflict in file X. Attempting to resolve..." "Merge failed. Retrying..." (Repeated 5+ times without success)
The Cause
Claude Cowork is tenacious. When it encounters a git merge conflict, it tries to fix it by reading the conflict markers (<<<<<<<). However, sometimes its "fix" introduces new syntax errors or conflicts, causing the next commit/merge attempt to fail again. This creates a "doom loop" where it keeps editing and failing.
The Fix
1. Stop the Agent (Ctrl+C)
First, you must break the loop. If you are using the CLI, hit Ctrl+C. If using the UI, click Stop.
2. Manual Resolution (The "God Mode" Fix)
Claude is bad at visualizing 3-way merges.
- Open the conflicted file in your IDE (VS Code, etc.).
- Use the IDE's merge conflict tool to pick "Current Change" or "Incoming Change".
- Save the file.
- Tell Claude: "I have manually resolved the conflict in
file.ts. Please proceed with the commit."
3. The "Abort and Retry" Strategy
If the repo is messy:
- Tell Claude: "Run
git merge --abortto reset." - Ask it to try the merge again, but this time, give it a specific strategy:
"Merge
feature-branchintomainfavoring 'theirs' for any conflicts."
Prevention
- Small PRs: Don't let Claude accumulate 50 files of changes before merging.
- Pull Often: Tell Claude to run
git pull origin mainbefore starting any new task.
Share this article