Skip to content

jayantdahiya/git-auto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Auto

AI-powered git workflow automation tool using local Ollama LLM.

Features

  • 🧠 AI-Powered: Uses Ollama for local, privacy-first LLM processing
  • 🌿 Smart Branch Names: Generates semantic branch names following Conventional Branch specification
  • 📝 Conventional Commits: Creates commit messages following Conventional Commits spec
  • 🚀 PR Creation: Automatically creates GitHub/GitLab pull requests via CLI
  • Fast: Local processing with minimal overhead
  • 🔒 Private: No data sent to external APIs
  • 🔄 Auto-Retry: Built-in retry logic with exponential backoff for LLM requests
  • Validation: Smart validation of generated branch names and commit messages

Installation

Prerequisites

  • Python 3.11+
  • Ollama running locally
  • GitHub CLI (gh) or GitLab CLI (glab) for PR creation

Install with uv

# Clone and install
git clone https://github.com/yourusername/git-auto.git
cd git-auto
uv sync

# Pull an Ollama model
ollama pull qwen2.5-coder:latest

Quick Start

# Stage your changes
git add .

# Run the automated workflow
uv run git-auto auto

# Or with options
uv run git-auto auto --dry-run              # Preview without executing
uv run git-auto auto --create-pr            # Create PR after push
uv run git-auto auto --model llama3.2       # Use different model
uv run git-auto auto --no-confirm           # Skip confirmation prompts

Commands

git-auto auto

Main workflow command that:

  1. Analyzes staged git changes (files, insertions, deletions, diffs)
  2. Infers change type (feat, fix, docs, refactor, etc.)
  3. Generates a semantic branch name using AI
  4. Creates a conventional commit message using AI
  5. Validates generated content
  6. Creates the branch and commits
  7. Pushes to remote (optional)
  8. Creates a pull request with AI-generated description (optional)

Options:

Option Description
-a, --add Stage all changes before running (git add -A)
-b, --base-branch Base branch for PR (default: main)
-n, --branch-name Override generated branch name
-m, --commit-msg Override generated commit message
-d, --dry-run Preview actions without executing
--no-confirm Skip confirmation prompts
--create-pr Create pull request after push
--model Ollama model to use
--skip-push Skip pushing to remote

git-auto config

View current configuration settings including Ollama host, model, and behavior options.

git-auto init

Create a default configuration file (.gitautorc) in the specified path.

uv run git-auto init              # Creates .gitautorc in current directory
uv run git-auto init --path ~/    # Creates in home directory

git-auto models

List available Ollama models with their sizes and modification dates.

Configuration

Create a .gitautorc file in your project root or home directory:

ollama:
  host: "http://localhost:11434"
  model: "qwen2.5-coder:latest"
  temperature: 0.3

git:
  default_base_branch: "main"
  auto_push: true

behavior:
  require_confirmation: true
  verbose: false

Configuration Priority

  1. Command-line arguments (highest priority)
  2. Project-level .gitautorc
  3. Home directory ~/.gitautorc
  4. Default values

Conventional Branch Names

Generated branch names follow the format: <type>/<description>

Type Purpose
feature New features
bugfix Bug fixes
hotfix Critical fixes
refactor Code restructuring
docs Documentation
test Test additions
chore Maintenance
perf Performance improvements

Conventional Commits

Generated commit messages follow the format: <type>(<scope>): <description>

Supported Types:

  • feat - New features
  • fix - Bug fixes
  • docs - Documentation changes
  • test - Test additions or modifications
  • refactor - Code restructuring without behavior changes
  • chore - Maintenance tasks
  • perf - Performance improvements
  • style - Code style changes

Examples:

  • feat(auth): add JWT token validation
  • fix(api): handle null response in user endpoint
  • docs(readme): update installation instructions
  • refactor(utils): extract common validation logic

Project Structure

git-auto/
├── git_auto/
│   ├── __init__.py           # Package initialization
│   ├── cli.py                # CLI entry point (Click-based)
│   ├── git_analyzer.py       # Git diff and change analysis
│   ├── llm_engine.py         # Ollama LLM integration
│   ├── branch_manager.py     # Branch creation and management
│   ├── commit_manager.py     # Commit message handling
│   ├── pr_creator.py         # GitHub/GitLab PR creation
│   ├── config.py             # Configuration management
│   ├── prompts.py            # LLM prompt templates
│   ├── validators.py         # Input/output validation
│   ├── utils.py              # CLI utilities and helpers
│   └── exceptions.py         # Custom exceptions
├── tests/
│   ├── conftest.py           # Pytest fixtures
│   ├── test_git_analyzer.py  # Git analyzer tests
│   ├── test_llm_engine.py    # LLM engine tests
│   ├── test_branch_manager.py # Branch manager tests
│   └── test_integration.py   # Integration tests
├── pyproject.toml            # Project configuration
├── .gitautorc                # Default configuration
└── README.md

Development

# Install dev dependencies
uv sync

# Run tests
uv run pytest tests/ -v

# Run with coverage
uv run pytest tests/ -v --cov=git_auto

# Run specific test file
uv run pytest tests/test_git_analyzer.py -v

Dependencies

Package Purpose
click CLI framework
gitpython Git repository interaction
ollama Ollama API client
pyyaml Configuration file parsing
rich Beautiful terminal output
requests HTTP requests

Troubleshooting

Ollama Connection Issues

# Check if Ollama is running
curl http://localhost:11434/api/tags

# Start Ollama
ollama serve

# Pull a model if not available
ollama pull qwen2.5-coder:latest

PR Creation Fails

Ensure the appropriate CLI tool is installed and authenticated:

# GitHub
gh auth login

# GitLab
glab auth login

Model Not Found

List available models and update your configuration:

uv run git-auto models
# Update .gitautorc with an available model name

License

MIT

About

AI-powered git workflow automation tool using local Ollama LLM.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors