AI-powered commit message helper that analyzes your Git diff and generates commit messages using OpenAI or a local LLM (like Ollama).
- Analyze staged diffs and suggest commit messages using Ai
- Use OpenAI (
gpt-4
) or a local model (via Ollama) - Edit messages inline before committing
- Doctor command to validate environment setup
- Clone the repository:
git clone https://github.com/paulocsb/git-commit-ai.git
cd git-commit-ai
- Install with pip (in editable mode):
pip install -e .
- (Optional) Add the CLI to your
$PATH
to run it likegit commit-ai
:
chmod +x bin/git-commit-ai
ln -s "$(pwd)/bin/git-commit-ai" /usr/local/bin/git-commit-ai
✅ You can now run it like a native Git command:
git commit-ai
Create a .env
file in the project root (or set env vars):
OPENAI_API_KEY=sk-...
OLLAMA_LANGUAGE_MODEL=llama3.2-vision
git add .
git commit-ai
Generates a commit message based on staged changes and prompts:
Suggested commit message:
✨ Add user authentication with token-based login
Commit message?/Edit/Cancel (Y/e/n):
git commit-ai -a openai --openai-api-key sk-...
Or rely on your .env
:
export OPENAI_API_KEY=sk-...
git commit-ai -a openai
git commit-ai --ollama-language-model llama2
Check if your environment is ready:
git commit-ai --doctor
Flag | Description |
---|---|
-a, --agent |
Choose between local or openai |
--openai-api-key |
Set your OpenAI API key |
--ollama-language-model |
Specify Ollama model name (default: llama3.2-vision ) |
-d, --doctor |
Run diagnostic checks |
git add .
git commit-ai -a openai
# Generates and suggests a commit message
# Prompts you to confirm, edit, or cancel
This project uses:
- Python 3.8+
- python-dotenv
- OpenAI API
- Ollama for local LLMs
To run from source:
python bin/git-commit-ai