Skip to content

A developer-friendly CLI tool that generates smart Git commit messages from your code changes using GPT models (OpenAI) or local LLMs like CodeLlama via Ollama.

License

Notifications You must be signed in to change notification settings

puneetkakkar/gpt-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gpt-commit logo

gpt-commit

🚀 Automatically generate Git commit messages using GPT (OpenAI) or local models via Ollama.

✨ Features

  • 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

📦 Installation

From PyPI

pip install gpt-commit

From Source

git clone https://github.com/yourusername/gpt-commit.git
cd gpt-commit
pip install -e .

🔧 Setup

OpenAI Backend

  1. Get your API key from OpenAI
  2. Set the environment variable:
    export OPENAI_API_KEY='your-api-key'
    Or create a .env file in your project root:
    OPENAI_API_KEY=your-api-key
    

Ollama Backend

  1. Install Ollama
  2. Pull a model (e.g., CodeLlama):
    ollama pull codellama

🚀 Usage

  1. Stage your changes:

    git add .
  2. 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

🔍 Options

  • --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

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A developer-friendly CLI tool that generates smart Git commit messages from your code changes using GPT models (OpenAI) or local LLMs like CodeLlama via Ollama.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published