🚀 Automatically generate Git commit messages using GPT (OpenAI) or local models via Ollama.
- Uses
git diff --cached
to summarize staged changes - Works with OpenAI GPT models (gpt-3.5-turbo, gpt-4)
- Supports local LLMs via Ollama
- CLI tool: simple, fast, dev-friendly
pip install gpt-commit
git clone https://github.com/yourusername/gpt-commit.git
cd gpt-commit
pip install -e .
- Get your API key from OpenAI
- Set the environment variable:
Or create a
export OPENAI_API_KEY='your-api-key'
.env
file in your project root:OPENAI_API_KEY=your-api-key
- Install Ollama
- Pull a model (e.g., CodeLlama):
ollama pull codellama
-
Stage your changes:
git add .
-
Generate a commit message:
# Using OpenAI (default) gpt-commit --backend openai --model gpt-4 # Using Ollama gpt-commit --backend ollama --model codellama # Auto-commit with the generated message gpt-commit --commit
--backend
: Choose between 'openai' or 'ollama' (default: 'ollama')--model
: Specify the model name (default: 'gpt-4' for OpenAI, 'codellama' for Ollama)--commit
: Automatically commit with the generated message
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.