Skip to main content

AI-powered git merge conflict resolver — Claude, OpenAI, or local Ollama

Project description

mergefix

AI-powered git merge conflict resolver — resolve conflicts in seconds, not minutes.

mergefix reads your conflict markers, understands what both sides were trying to do, and produces the correct merged result — preserving intent from both branches.

$ mergefix
Scanning for conflict markers…

→ src/auth.py  (2 conflicts)

  Conflict 1/2
  ours:   HEAD
  theirs: feature/oauth

  ✓ Resolution:
    def authenticate(user, provider=None):
        if provider == "oauth":
            return oauth_login(user)
        return password_login(user)

  Conflict 2/2
  ours:   HEAD
  theirs: feature/oauth

  ✓ Resolution:
    SUPPORTED_PROVIDERS = ["password", "oauth", "sso"]

Diff:
  --- a/src/auth.py
  +++ b/src/auth.py
  @@ -8,8 +8,8 @@
  -<<<<<<< HEAD
  -    return password_login(user)
  -=======
  -    ...
  ->>>>>>> feature/oauth
  +    def authenticate(user, provider=None):
  +        if provider == "oauth":
  +            ...

Apply resolutions to src/auth.py? [Y/n]  y
  ✓ Applied

✅ All 1 file(s) resolved.
Run `git diff` to review changes, then `git add` to mark as resolved.

Install

pip install mergefix

Set your API key (or use Ollama for free local resolution):

export ANTHROPIC_API_KEY=your-key   # Claude (default)
export OPENAI_API_KEY=your-key      # or OpenAI
# or use --provider ollama           # local, no API key needed

Usage

# Resolve all conflicted files in current directory
mergefix

# Resolve a specific file
mergefix src/auth.py

# Preview resolutions without writing
mergefix --preview

# Apply all without prompting (scripting/CI use)
mergefix --yes

# Keep original files as .orig backups
mergefix --backup

# Use local Ollama (free, no API key)
mergefix --provider ollama

# Use OpenAI
mergefix --provider openai

# Custom model
mergefix --provider claude --model claude-haiku-4-5-20251001

How It Works

  1. Finds all files with <<<<<<< conflict markers in the current directory
  2. For each conflict block, extracts ours, theirs, and (if present) the common base
  3. Sends the conflict + surrounding context to the LLM with a structured prompt
  4. The AI preserves intent from both sides — it doesn't just pick one
  5. Shows you a colorized diff before writing anything
  6. Writes the resolved file on confirmation (or with --yes for automation)

Context-Aware Resolution

mergefix doesn't blindly pick a side. It:

  • Includes lines before and after the conflict so the AI understands the code context
  • Provides commit messages from each branch (when available) so the AI understands why each change was made
  • Handles diff3-style (3-way) conflicts with the common ancestor

What mergefix Does Well

  • Additive changes: Feature A adds a function, Feature B adds another → keep both
  • Same line, different values: Config changes, version bumps → AI picks the right one
  • Refactoring meets feature: One side renamed a function while another added to it
  • Import conflicts: Merges import lists cleanly
  • Documentation conflicts: Merges docstring changes from both sides

Integration

# After git merge or git rebase hits conflicts:
git merge feature/branch
# Lots of conflicts...

mergefix --yes          # auto-resolve all
git diff                # review the AI's choices
git add .               # mark as resolved
git commit

Providers

Provider Command Notes
Claude (default) --provider claude Best results; requires ANTHROPIC_API_KEY
OpenAI --provider openai Requires OPENAI_API_KEY
Ollama --provider ollama Free, runs locally; no API key needed
# Default models
mergefix --provider claude    # claude-haiku-4-5-20251001
mergefix --provider openai    # gpt-4o-mini
mergefix --provider ollama    # qwen2.5:1.5b

# Override model
mergefix --provider claude --model claude-sonnet-4-6

Developer Workflow Integration

mergefix fits into the AI-powered git workflow:

# 1. Morning: generate standup from yesterday's commits
standup-ai ~/projects/myapp

# 2. Rebase or merge, hit conflicts
git rebase main
mergefix --yes              # AI resolves all conflicts
git rebase --continue

# 3. Review staged changes before committing
critiq                      # AI code review

# 4. Generate commit message
gpr --commit-run

# 5. Generate PR description
gpr

# 6. At release: generate CHANGELOG
changelog-ai --from v0.1.0 --prepend CHANGELOG.md

Related Tools

  • critiq — AI code reviewer: catch issues before you push
  • critiq-vscode — VS Code extension for critiq
  • gpr — AI commit messages + PR descriptions
  • gitbrief — git-history-aware context packer for LLMs
  • standup-ai — daily standup from git commits
  • prcat — AI reviewer for teammates' pull requests
  • changelog-ai — AI-generated CHANGELOG
  • git-chronicle — AI git history narrator

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mergefix-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mergefix-0.1.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file mergefix-0.1.0.tar.gz.

File metadata

  • Download URL: mergefix-0.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for mergefix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b435b19217a6a4ef58dce7b05cf06ef5a8255c34a3a8578664aae7922255d9d
MD5 e97f76aeb52a0875daa49ce127a389fe
BLAKE2b-256 7ed0736827cd92818a25b0ccd431e48281e9794a816022e1f649eab22e25bd49

See more details on using hashes here.

File details

Details for the file mergefix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mergefix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for mergefix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7d804303a9929a223091cbe40b1ee106159398146f4e75d8863a91b27621f66
MD5 34b0d5c9c7736247daec2099d0317257
BLAKE2b-256 5a3b98f6ac3e9069a5ac230c3d1de9e943d5ffac379754c95a720a8f75c1bbc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page