AI-powered git workflow automation tool using local Ollama LLM.
- 🧠 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
- Python 3.11+
- Ollama running locally
- GitHub CLI (
gh) or GitLab CLI (glab) for PR creation
# 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# 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 promptsMain workflow command that:
- Analyzes staged git changes (files, insertions, deletions, diffs)
- Infers change type (feat, fix, docs, refactor, etc.)
- Generates a semantic branch name using AI
- Creates a conventional commit message using AI
- Validates generated content
- Creates the branch and commits
- Pushes to remote (optional)
- 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 |
View current configuration settings including Ollama host, model, and behavior options.
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 directoryList available Ollama models with their sizes and modification dates.
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- Command-line arguments (highest priority)
- Project-level
.gitautorc - Home directory
~/.gitautorc - Default values
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 |
Generated commit messages follow the format: <type>(<scope>): <description>
Supported Types:
feat- New featuresfix- Bug fixesdocs- Documentation changestest- Test additions or modificationsrefactor- Code restructuring without behavior changeschore- Maintenance tasksperf- Performance improvementsstyle- Code style changes
Examples:
feat(auth): add JWT token validationfix(api): handle null response in user endpointdocs(readme): update installation instructionsrefactor(utils): extract common validation logic
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
# 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| Package | Purpose |
|---|---|
click |
CLI framework |
gitpython |
Git repository interaction |
ollama |
Ollama API client |
pyyaml |
Configuration file parsing |
rich |
Beautiful terminal output |
requests |
HTTP requests |
# 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:latestEnsure the appropriate CLI tool is installed and authenticated:
# GitHub
gh auth login
# GitLab
glab auth loginList available models and update your configuration:
uv run git-auto models
# Update .gitautorc with an available model nameMIT