---
title: "Merge Conflict Auto-Fix"
description: "Automatically resolve merge conflicts in your pull requests."
section: "automation"
url: "https://forkline.dev/docs/automation/merge-conflicts"
markdown: "https://forkline.dev/docs/automation/merge-conflicts.md"
source: "src/content/docs/automation/merge-conflicts.mdx"
---

# Merge Conflict Auto-Fix

Automatically resolve merge conflicts on pull requests caused by parallel development.

## Overview

Conflict automation helps when one branch lands and leaves another branch no longer mergeable. Forkline focuses on getting the branch back into a reviewable state quickly.

_Interactive figure (MergeConflictDiagram) — see the HTML version of this page._

## Enabling Merge Conflict Auto-Fix

1. Navigate to **Repositories**
2. Find your repository
3. Click **Settings** on the repository card
4. Select the **Automation** tab in the modal
5. Find **Merge Conflict Auto-Fix**
6. Set the mode to **Enable for this repository**
7. Set **Maximum resolution attempts per PR**
8. Click **Save**

## How It Works

### Conflict Detection

When a pull request's base branch advances, the provider sends an update event. If the branch is no longer mergeable, Forkline creates a resolution task.

Some self-hosted forges report only *whether* a branch is mergeable, never *why*, and that answer can
still mean "the check has not finished". Where the report is ambiguous, Forkline confirms the conflict
itself by merging the two commits the forge named before starting a task, so a branch with an unsettled
check is not announced as conflicting. The task then starts as soon as a real conflict is confirmed,
which can take a minute or two longer than the forge's own answer.

### Draft Pull Requests

Draft (work-in-progress) pull requests are never auto-fixed, matching how auto-review skips them.
A forge reports a draft branch as not mergeable even when nothing conflicts, and a draft is not
meant to be merged yet.

Marking a pull request ready for review does not by itself start a conflict check. The next push
to the pull request's branch, or to the branch it targets, is what picks it up.

### Resolution Process

1. Fetch base-branch changes
2. Identify conflicting files
3. Analyze conflict markers and surrounding code
4. Generate a resolution
5. Push changes back to the PR branch

## Result Comments

### Starting

```markdown
🔀 Merge conflicts detected with `main`

Automatically resolving conflicts in:
- src/api/users.ts
- src/utils/validation.ts

Attempt 1/3
```

### Success

```markdown
✅ Merge conflicts resolved!

Pushed commit abc1234 to your branch.

Resolved conflicts in:
- src/api/users.ts (merged function signatures)
```

## Limitations

Merge conflict automation may not resolve:

- Semantic conflicts where the code compiles but behaves incorrectly
- Complex multi-file refactors
- Conflicts that require architectural decisions

> **Warning**: Always review the result. Automatic conflict resolution is a convenience, not a correctness guarantee.

## Next Steps

- [Learn about CI auto-fix](https://forkline.dev/docs/automation/ci-auto-fix)
- [Configure trigger policies](https://forkline.dev/docs/automation/trigger-policies)
