CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/Claude Code
Claude Code/2026-03-30Intermediate

How to Auto-Resolve Git Conflicts with Claude Code — Merge and Rebase Strategies

Learn how to resolve Git merge conflicts efficiently using Claude Code. This guide covers 3-way merge fundamentals, rebase conflict handling, complex resolution patterns, and automation techniques with practical command examples.

claude-code129git16conflict-resolutionmergerebaseteam-development2

Why Use Claude Code for Git Conflict Resolution

In team development, Git merge conflicts are an inevitable part of the workflow. When multiple developers edit the same files simultaneously, running git merge or git rebase frequently results in conflicts that consume valuable development time.

Claude Code is an AI coding agent that operates directly from the terminal, capable of understanding code context at a deep level to resolve conflicts intelligently. Unlike traditional diff tools that compare text line by line, Claude Code analyzes what the code actually does and proposes contextually appropriate merge results.

How Merge Conflicts Occur

Before diving into resolution techniques, let's briefly review why conflicts happen in the first place.

Git uses a 3-way merge algorithm that compares changes from two branches against their common ancestor (base) to automatically merge them.

  • Base: The file content at the point where both branches diverged
  • Ours: Changes in the currently checked-out branch
  • Theirs: Changes in the branch being merged

When the same lines have been modified differently in both branches, Git cannot auto-merge and inserts conflict markers (<<<<<<<, =======, >>>>>>>) into the file, requesting manual resolution.

# Conflict marker example
<<<<<<< HEAD
const API_ENDPOINT = "https://api.example.com/v2";
=======
const API_ENDPOINT = "https://api.example.com/v3";
>>>>>>> feature/update-api

In this example, HEAD (the current branch) uses v2, while feature/update-api uses v3 — Git cannot determine which version to keep.

Basic Steps for Resolving Conflicts with Claude Code

Step 1: Assess the Conflict State

When a conflict occurs after a merge or rebase, inform Claude Code about the situation.

# After a merge with conflicts
git merge feature/update-api
# CONFLICT (content): Merge conflict in src/config.ts
 
# Ask Claude Code to resolve it
claude "A git merge conflict occurred. Please review and resolve all conflicts."

Claude Code will automatically perform the following steps:

  • Run git status to list conflicted files
  • Examine the diffs in each file
  • Analyze the conflict markers and propose an appropriate resolution
  • Edit the files to eliminate conflicts

Step 2: Review the Resolution

Always review the resolution Claude Code proposes. Crafting a more specific prompt leads to more accurate results.

# Prompt with explicit resolution policies
claude "Please resolve the git merge conflicts with the following policies:
- Prioritize changes from the feature branch
- Keep type definition changes from the main branch
- Integrate both sets of changes for test files"

Step 3: Commit and Finalize

After verifying that conflicts are resolved, stage and commit.

# Stage resolved files
git add .
 
# Create the merge commit
git commit -m "Merge feature/update-api: API v3 migration with test integration"

Handling Rebase Conflicts

Unlike merge, git rebase can trigger conflicts on a per-commit basis. When rebasing a branch with many commits, you may encounter conflicts on the same file multiple times.

# Start a rebase
git rebase main
 
# When a conflict occurs
# CONFLICT (content): Merge conflict in src/utils/parser.ts
# error: could not apply abc1234... Add parser utility
 
# Ask Claude Code for help
claude "A conflict occurred during rebase.
Current commit: abc1234 (Add parser utility)
Please resolve the conflict in src/utils/parser.ts
so I can run git rebase --continue"

With rebase, you need to run git rebase --continue after resolving each conflict. Communicating this flow to Claude Code streamlines the process.

# Automate sequential rebase conflict resolution
claude "Please resolve the rebase conflicts one by one.
After resolving each conflict, run git add and git rebase --continue.
If there's another conflict, continue resolving it.
Report the final result when everything is complete."

Practical Techniques: Complex Conflict Patterns

Pattern 1: Simultaneous Function Rename and Implementation Change

When one branch renames a function while another modifies its implementation, manual resolution becomes particularly challenging.

claude "Please perform a detailed conflict analysis:
- The main branch renamed processData() to transformData()
- The feature branch added validation logic to processData()
Reflect both changes by applying the new validation logic to transformData()"

Pattern 2: package.json and Lock File Conflicts

Dependency file conflicts are extremely common and prone to version inconsistencies when resolved manually.

# Resolve package.json conflict
claude "Please resolve the package.json conflict.
Policy: include all dependencies added by both branches.
If versions differ, adopt the newer one."
 
# Regenerate the lock file for safety
npm install
# or
yarn install

Pattern 3: Configuration File Structure Changes

Claude Code is also effective for conflicts in JSON/YAML configuration files like tsconfig.json or ESLint configs.

claude "Please resolve the tsconfig.json conflict:
- The main branch modified strict mode settings
- The feature branch added path aliases
Maintain valid JSON structure while reflecting both changes"

Automating Conflict Resolution with Claude Code Hooks

Claude Code's Hooks feature lets you automatically detect conflicts and streamline the resolution workflow.

Add the following configuration to .claude/settings.json:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "if git status --porcelain | grep -q '^UU\\|^AA\\|^DD'; then echo 'CONFLICT_DETECTED: Conflicted files found'; fi"
          }
        ]
      }
    ]
  }
}

This configuration auto-detects conflict states after Claude Code executes Bash commands. For more advanced automation patterns, check out our Claude Code Hooks Workflow Automation Guide.

Best Practices for Conflict Prevention

Preventing conflicts is just as important as knowing how to resolve them.

Rebase frequently: The longer a branch stays diverged, the larger the conflicts become. Run git rebase main regularly to keep the diff small.

Keep branches granular: Implementing multiple features in a single branch widens the scope of potential conflicts. Split branches by feature and merge frequently.

Use CODEOWNERS files: Assigning file ownership reduces the likelihood of multiple developers editing the same files simultaneously.

Communicate: Simply sharing "I'm working on these files right now" within your team can dramatically reduce conflicts.

For a comprehensive look at team Git workflows, see our Claude Code Team Development Guide covering branch strategies and automated reviews.

Useful Git Commands for Conflict Diagnosis

Knowing how to gather accurate information before passing it to Claude Code leads to better results.

# List all conflicted files
git diff --name-only --diff-filter=U
 
# Show detailed 3-way diff
git diff --cc
 
# Inspect the 3-way merge state of a specific file
git show :1:src/config.ts  # base (common ancestor)
git show :2:src/config.ts  # ours (current branch)
git show :3:src/config.ts  # theirs (incoming branch)
 
# Abort a merge and start over
git merge --abort
 
# Abort a rebase and start over
git rebase --abort

You can feed these outputs to Claude Code for more precise conflict resolution.

# Pass 3-way diff information to Claude Code
claude "Please resolve the conflict based on this 3-way diff:
$(git diff --cc src/config.ts)"

Looking back

Using Claude Code for Git conflict resolution delivers more than just time savings — it provides context-aware merge results that understand the intent behind your code. The benefits are especially apparent when dealing with sequential rebase conflicts or complex cases where function renames and implementation changes overlap.

By clearly communicating your resolution policies, always reviewing the results, and combining resolution skills with prevention strategies, you can significantly streamline your team's Git workflow. To dive deeper into Git workflow automation, be sure to explore Automating Git Workflows with Claude Code as well.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Claude Code2026-04-26
Sharing Claude Code's .claude/ directory across a team — what to commit and what to keep personal
When you start sharing Claude Code's .claude/ directory across a team, which files belong in Git and which stay local? Here are the boundaries I've drawn after running it on four projects, plus a working .gitignore template.
Claude Code2026-07-14
One Day My Push Had an Extra Destination — Guarding Against /commit-push-pr Pushing to Remotes Beyond origin
The July 14 update made /commit-push-pr push to configured push remotes in addition to origin. Convenient, but if you keep a mirror or backup as a second remote, unintended pushes quietly multiply. Here is how to inventory which remotes you can push to, block anything off the allowlist with a pre-push hook, and keep unattended runs safe — with working code.
Claude Code2026-06-10
When git add -A Sweeps Up .bak Backups — The Quiet Trap of In-Place Fix Scripts
How .bak backups left by sed -i and homegrown --fix scripts get silently swept into production by git add -A, why it is so easy to miss, and how scoped adds and .gitignore close the gap for good.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →