Generate beautiful, conventional commit messages from your staged diffs using AI.
╔══════════════════════════════════════╗
║ 🤖 git-ai-commit ║
║ AI-powered commit messages ║
╚══════════════════════════════════════╝
Installation • Quick Start • Features • Configuration • Backends • Contributing
$ git add .
$ git-ai-commit
╔══════════════════════════════════════╗
║ 🤖 git-ai-commit ║
║ AI-powered commit messages ║
╚══════════════════════════════════════╝
📋 Staged Changes
┌─────────────────────────────────────────┐
│ File │
├─────────────────────────────────────────┤
│ src/auth/login.py │
│ src/auth/middleware.py │
│ tests/test_login.py │
└─────────────────────────────────────────┘
⏳ Generating with openai (gpt-4o)...
╭──────── ✨ Suggested Commit ────────╮
│ │
│ feat(auth): add JWT refresh token │
│ │
│ Implement automatic token refresh │
│ to prevent session expiry during │
│ active user sessions. │
│ │
╰──────────── Feature ────────────────╯
[a] Accept & commit
[e] Edit message
[r] Regenerate
[q] Quit
Choose [a]:
✅ Committed successfully!
pip install git-ai-commit# OpenAI
pip install "git-ai-commit[openai]"
# Anthropic
pip install "git-ai-commit[anthropic]"
# All backends
pip install "git-ai-commit[all]"pipx install git-ai-commitbrew install nousresearch/tap/git-ai-commitgit clone https://github.com/zzc18429155766/git-ai-commit.git
cd git-ai-commit
pip install -e ".[all]"# OpenAI (default)
export OPENAI_API_KEY="sk-..."
# Or Anthropic
export ANTHROPIC_API_KEY="sk-ant-..."
# Or use local Ollama (no key needed)
ollama pull llama3.1git add .
git-ai-commitThat's it! 🎉
| Feature | Description |
|---|---|
| 🎯 Conventional Commits | Automatically detects type (feat, fix, refactor, etc.) |
| 🧠 Multi-AI Backend | OpenAI, Anthropic, and local Ollama support |
| 💬 Interactive Mode | Accept, edit, or regenerate suggestions |
| ⚡ Auto-commit | One-step generate + commit |
| 📝 Commit Body | Generates detailed commit body explaining the why |
| 🎨 Beautiful Output | Rich terminal UI with colors and panels |
| ⚙️ Configurable | .git-ai-commit.yml config file support |
| 🌍 Multi-language | Generate messages in any language |
| 🔍 Breaking Changes | Detects and marks breaking changes with ! |
| 🏷️ Scopes | Auto-detects scope from changed files |
| 📦 Lightweight | Minimal dependencies, fast startup |
git-ai-commit
# or as git subcommand
git ai-commitShows a suggested commit message and lets you accept, edit, regenerate, or quit.
git-ai-commit --auto
# or
git-ai-commit -aGenerates and commits in one step — perfect for rapid development.
git-ai-commit --dry-runPreview the generated message without committing.
git-ai-commit --backend openai
git-ai-commit --backend anthropic
git-ai-commit --backend ollamagit-ai-commit --model gpt-4o-mini
git-ai-commit --model claude-sonnet-4-20250514
git-ai-commit --model codellamagit-ai-commit --emojiPrefixes the subject with the appropriate gitmoji: ✨ feat: add login
git-ai-commit --language zh # Chinese
git-ai-commit --language ja # Japanese
git-ai-commit --language es # Spanishgit-ai-commit --signoffAdds Signed-off-by trailer to the commit.
git-ai-commit --amendCreate a .git-ai-commit.yml in your project root or home directory:
# AI backend: openai | anthropic | ollama
backend: openai
# Model to use (optional — uses backend default)
model: gpt-4o
# Auto-commit without interactive prompt
auto_commit: false
# Generate commit message body
include_body: true
# Max subject line length
max_subject_length: 72
# Temperature (0.0 - 1.0) — lower = more deterministic
temperature: 0.3
# Language for commit messages
language: en
# Add emoji prefix
emoji: false
# Add Signed-off-by
signoff: false
# Restrict allowed commit types
allowed_types:
- feat
- fix
- refactor
- docs
- chore
- perf
- test
# Ollama-specific: custom URL
ollama_url: http://localhost:11434| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
ANTHROPIC_API_KEY |
Anthropic API key |
GAC_BACKEND |
Override backend |
GAC_MODEL |
Override model |
export OPENAI_API_KEY="sk-..."
git-ai-commit --backend openai --model gpt-4oDefault model: gpt-4o
export ANTHROPIC_API_KEY="sk-ant-..."
git-ai-commit --backend anthropicDefault model: claude-sonnet-4-20250514
# 1. Install Ollama: https://ollama.ai
# 2. Pull a model
ollama pull llama3.1
# 3. Use it
git-ai-commit --backend ollama --model llama3.1No API key required. Runs 100% locally. 🔒
git config --global alias.ai '!git-ai-commit'Then use:
git ai
git ai --auto# .git/hooks/prepare-commit-msg
#!/bin/bash
if [ -z "$COMMIT_MSG_SOURCE" ]; then
git-ai-commit --auto
fi# Clone
git clone https://github.com/zzc18429155766/git-ai-commit.git
cd git-ai-commit
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check .
ruff format .
# Type check
mypy git_ai_commit/Q: Is my code sent to the cloud?
A: If you use OpenAI or Anthropic, yes — only the diff (not your full codebase) is sent. With Ollama, everything stays local.
Q: Does it work with any git repo?
A: Yes! Any git repository with staged changes.
Q: Can I use it with GitHub/GitLab?
A: Absolutely. It creates standard git commits that work with any remote.
Q: What if I don't have an API key?
A: Use Ollama — it's free and runs locally.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
# Fork, clone, create branch
git checkout -b feat/my-feature
# Make changes, test
pytest
# Submit PRMIT License — see LICENSE for details.
If you find this tool useful, consider buying me a coffee!