Skip to content

paulocsb/git-commit-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 git-commit-ai

AI-powered commit message helper that analyzes your Git diff and generates commit messages using OpenAI or a local LLM (like Ollama).


🚀 Features

  • 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

Installation

  1. Clone the repository:
git clone https://github.com/paulocsb/git-commit-ai.git
cd git-commit-ai
  1. Install with pip (in editable mode):
pip install -e .
  1. (Optional) Add the CLI to your $PATH to run it like git 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

Configuration

Create a .env file in the project root (or set env vars):

OPENAI_API_KEY=sk-...
OLLAMA_LANGUAGE_MODEL=llama3.2-vision

Usage

Basic usage

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):

Use OpenAI instead of local agent

git commit-ai -a openai --openai-api-key sk-...

Or rely on your .env:

export OPENAI_API_KEY=sk-...
git commit-ai -a openai

Use a custom local model

git commit-ai --ollama-language-model llama2

Doctor command

Check if your environment is ready:

git commit-ai --doctor

CLI Options

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

Example Workflow

git add .
git commit-ai -a openai
# Generates and suggests a commit message
# Prompts you to confirm, edit, or cancel

Development

This project uses:

To run from source:

python bin/git-commit-ai

About

AI-powered Git commit message generator

Resources

License

Stars

Watchers

Forks

Languages