Skip to content

Repository files navigation

Git Commit Message Generator

An AI-powered CLI tool that analyzes your staged changes and generates structured, conventional commit messages using LangChain and Ollama.

Setup

Note

While the following guide specifically targets Arch Linux and the Fish shell, main.py is entirely platform-independent. You can easily adapt the shortcut command for Bash, Zsh, or Windows (PowerShell).

  1. Clone the Repository (to ~/tools/)

  2. Congigure Environment Variables (Optional) If you are using a custom Ollama setup, you can set these in your shell configuration (e.g. ~/.config/fish/config.fish):

    set -gx OLLAMA_BASE_URL "http://localhost:11434"  # Your Ollama URL
    set -gx OLLAMA_MODEL "gemma4:31b-cloud"           # Your preferred model
  3. Create Fish Shell Function

    # ~/.config/fish/functions/gcm.fish
    function gcm --description "Generate git commit message using AI (via uv venv)"
         if not git rev-parse --is-inside-work-tree >/dev/null 2>&1
             echo "Error: Not a git repository (or any of the parent directories)"
             return 1
         end
        ~/tools/gcm/.venv/bin/python ~/tools/gcm/main.py
    end

How It Works

  1. Rule Ingestion: Reads [simple_]commit_message_rule.md to strictly follow the Conventional Commits specification.

  2. Log Analysis: Fetches commit history from the current branch using git log --oneline to understand your writing style.

  3. Diff Analysis: Automatically fetches staged changes using git diff --cached.

  4. AI Generation: Streams 3 distinct commit message options tailored to your codebase changes, letting you choose the best fit.

Usage

Stage your changes first, then run gcm from anywhere inside your repository:

# under repo dir
git add <some files>
gcm

About

Currently docs focus on Arch/Fish, but main.py runs anywhere

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages