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.

  1. Open the conflicted file in your IDE (VS Code, etc.).
  2. Use the IDE's merge conflict tool to pick "Current Change" or "Incoming Change".
  3. Save the file.
  4. 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:

  1. Tell Claude: "Run git merge --abort to reset."
  2. Ask it to try the merge again, but this time, give it a specific strategy: "Merge feature-branch into main favoring '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 main before starting any new task.