Skip to content

olllayor/aimerge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AIMerge - AI-Powered Git Merge Conflict Resolver

Python License Status

AIMerge is an intelligent Git merge conflict resolver that uses Google Gemini AI to automatically suggest and resolve merge conflicts. Say goodbye to manually resolving complex merge conflicts!

โœจ Features

  • ๐Ÿ” Automatic Conflict Detection - Scans your Git repository for merge conflicts
  • ๐Ÿค– AI-Powered Resolution - Uses Google Gemini to intelligently resolve conflicts
  • ๐ŸŽจ Color-Coded Diffs - Beautiful terminal output with syntax highlighting
  • ๐Ÿ’ฌ Interactive Mode - Review, edit, or accept AI suggestions
  • โšก Auto Mode - Batch resolve multiple conflicts automatically
  • ๐Ÿ”’ Safe Backups - Automatically backs up files before making changes
  • ๐Ÿ“Š Progress Tracking - Shows resolution statistics and progress

๐Ÿš€ Installation

Using pip (recommended):

pip install aimerge

Using uv:

uv add aimerge

From source:

git clone https://github.com/olllayor/aimerge.git
cd aimerge
pip install -e .

๐Ÿ”ง Setup

  1. Get a Google Gemini API Key:

  2. Configure AIMerge:

    # Set your API key (one-time setup)
    aimerge --set-api-key YOUR_GEMINI_API_KEY
    
    # Or set as environment variable
    export GEMINI_API_KEY="your-api-key-here"

๐Ÿ“– Usage

Basic Usage

Navigate to your Git repository with merge conflicts and run:

aimerge

Interactive Mode (default)

aimerge
  • Review each conflict individually
  • Choose to accept, skip, or edit AI suggestions
  • Get colored diffs showing the changes

Auto Mode (batch processing)

aimerge --auto
  • Automatically resolves all conflicts without prompts
  • Great for trusted repositories or batch processing

Help

aimerge --help

๐ŸŽฏ How It Works

  1. Detection: AIMerge scans your Git repository for files with merge conflicts
  2. Analysis: Each conflict is analyzed with surrounding context
  3. AI Resolution: Google Gemini generates intelligent merge suggestions
  4. Review: You can review, edit, or accept each suggestion
  5. Application: Resolved conflicts are applied and staged in Git

๐Ÿ“‹ Example Workflow

# You have merge conflicts after a git merge
$ git merge feature-branch
Auto-merging src/utils.py
CONFLICT (content): Merge conflict in src/utils.py

# Run AIMerge to resolve conflicts
$ aimerge
INFO: AIMerge initialized with your Google Gemini API key.
INFO: Found 1 conflicted file: src/utils.py

โ•ญโ”€ Conflict 1/1 in src/utils.py โ”€โ•ฎ
โ”‚ Current (HEAD):                 โ”‚
โ”‚ def calculate_sum(a, b):        โ”‚
โ”‚     return a + b                โ”‚
โ”‚                                 โ”‚
โ”‚ Incoming (feature-branch):      โ”‚
โ”‚ def calculate_sum(a, b, c=0):   โ”‚
โ”‚     return a + b + c            โ”‚
โ”‚                                 โ”‚
โ”‚ AI Suggestion:                  โ”‚
โ”‚ def calculate_sum(a, b, c=0):   โ”‚
โ”‚     """Calculate sum with optional third parameter."""  โ”‚
โ”‚     return a + b + c            โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Accept this resolution? [y/n/e/s]: y

โœ… Resolved 1/1 conflicts

๐Ÿ› ๏ธ Configuration

AIMerge supports several configuration options:

Environment Variables

export GEMINI_API_KEY="your-api-key"     # Required: Your Gemini API key
export AIMERGE_MODEL="gemini-1.5-pro"    # Optional: Specific model version

Command Line Options

aimerge --help                    # Show help
aimerge --set-api-key KEY         # Set API key
aimerge --auto                    # Auto-resolve all conflicts
aimerge --model gemini-1.5-flash  # Use specific model

๐Ÿงช Development

Setting Up Development Environment

git clone https://github.com/olllayor/aimerge.git
cd aimerge

# Install with development dependencies
pip install -e ".[dev]"

# Or using uv
uv sync

Running Tests

pytest

Project Structure

aimerge/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ cli.py                 # Main CLI interface
โ”‚   โ”œโ”€โ”€ conflict_detector.py   # Git conflict detection
โ”‚   โ”œโ”€โ”€ conflict_parser.py     # Conflict parsing logic
โ”‚   โ”œโ”€โ”€ gemini_resolver.py     # AI resolution logic
โ”‚   โ””โ”€โ”€ git_integration.py     # Git operations
โ”œโ”€โ”€ tests/                     # Test suite
โ””โ”€โ”€ pyproject.toml            # Project configuration

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

โš ๏ธ Disclaimer

  • AIMerge is in beta. Always review AI suggestions before accepting them.
  • Keep backups of important code before using auto-mode.
  • AI suggestions may not always be perfect - use your judgment.

๐Ÿ™ Acknowledgments

  • Google Gemini AI for providing the intelligent conflict resolution
  • The Git community for making version control awesome
  • All contributors and users of this project

๐Ÿ“ž Support


Made with โค๏ธ for developers who hate merge conflicts

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages