Skip to content

dnlmos/gcg

Repository files navigation

🚀 [G]it [C]ommit [G]enerate (gcg) — Auto-generate Git Commit Messages with AI

License: MIT Rust

gcg is a fast and lightweight CLI tool written in Rust that uses LLMs to automatically generate meaningful Git commit messages from your code changes.


✨ Features

  • 🔍 Parses your git diff files and suggests a relevant commit message.
  • 🤖 Supports multiple LLM providers:
    • Google Gemini
    • Local models via Ollama
    • OpenAI-compatible APIs
  • ⚡ Fast and efficient — written in Rust

🔧 Setup

  1. Clone the repository and build:
git clone https://github.com/daniel-mosko/gcg.git
cd gcg
cargo install --path .

Set your config:

You can provide a configuration file named gcg.yaml in one of the following locations:

  • In your project repository (local config)
  • In the global config directory: $HOME/.config/gcg/
  • Or rely on the default configuration shown below:
provider:
  name: "ollama"
  api_url: "http://127.0.0.1:11434/api/generate"
  model: "llama-3.2-3b-instruct:latest"
prompt_template: |
  You are an AI assistant that generates concise, short and clear Git commit messages from code diffs.

  ---
  **Guidelines for Commit Messages:**
  * Start with a **type** (e.g., `feat`, `fix`, `docs`, `refactor`, `chore`) followed by a colon and a space, then the **subject**.
  * The subject line should be **imperative**, **50 characters or less**, and concisely describe the change.
  * Optionally, include a blank line followed by a **body** with bullet points (`-`). Each bullet point should clearly explain a specific aspect of the change.
  * Focus strictly on the changes presented in the diff.
  ---

  **Code Diff to Analyze:**

Usage

gcg "repo/path"

Example response (based on the model)

feat: Add error handling to auth middleware
- Refactored login logic in auth.rs
- Added error messages for invalid tokens

About

[G]it [C]ommit [G]enerate CLI Tool written in Rust to auto-generate git commit message using LLM.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages