Skip to content

CJHwong/rs-git-msg

Repository files navigation

rs-git-msg

An AI-powered git commit message generator written in Rust.

Lazygit Integration Demo

Installation

Pre-built binaries (quickest)

Download and install directly from GitHub Releases:

# Linux (amd64)
curl -L https://github.com/CJHwong/rs-git-msg/releases/latest/download/rs-git-msg-linux-amd64 -o /usr/local/bin/rs-git-msg && chmod +x /usr/local/bin/rs-git-msg

# macOS (amd64)
curl -L https://github.com/CJHwong/rs-git-msg/releases/latest/download/rs-git-msg-macos-amd64 -o /usr/local/bin/rs-git-msg && chmod +x /usr/local/bin/rs-git-msg

Install script

git clone https://github.com/CJHwong/rs-git-msg.git
cd rs-git-msg
./scripts/install.sh

From source

cargo build --release
cp target/release/rs-git-msg ~/.local/bin/   # or /usr/local/bin/

Usage

# Stage some changes, then generate a commit message
git add .
rs-git-msg

CLI Options

Usage: rs-git-msg [OPTIONS]

Options:
  -n, --number <NUMBERS>    Number of commit messages to generate (1-5) [default: 1]
  -i, --instructions <INSTRUCTIONS>
                            Additional context or instructions for the AI
  -v, --verbose             Enable verbose output
  -p, --provider <PROVIDER> AI provider to use [default: ollama] [possible values: ollama, openai, gemini]
  -m, --model <MODEL>       Model name to use (defaults to provider's default)
  -k, --api-key <API_KEY>   API key for the provider (not needed for Ollama)
  -u, --api-url <API_URL>   API base URL (defaults to provider's standard URL)
      --diff-alg <DIFF_ALG> Diff algorithm to use [default: default] [possible values: default, patience, minimal, difftastic]
  -h, --help                Print help
  -V, --version             Print version

Examples

Ollama (default, no API key needed):

# Install Ollama: https://ollama.ai/download
ollama pull qwen3
rs-git-msg                     # uses default model
rs-git-msg -m qwen2.5-coder   # specify a different model

OpenAI:

rs-git-msg -p openai -m gpt-4o-mini -k your_api_key

Gemini:

export GEMINI_API_KEY="your-api-key"
rs-git-msg -p gemini
rs-git-msg -p gemini -m gemini-2.5-flash    # specify model
# Generate multiple options
rs-git-msg -n 3

# Add context for the AI
rs-git-msg -i "This fixes the login timeout bug"

# Verbose output for debugging
rs-git-msg -v

Environment Variables

Variable Description
GEMINI_API_KEY API key for Gemini (also used for OpenAI if no -k flag is passed)
RS_GIT_MSG_API_KEY Deprecated. Use GEMINI_API_KEY instead. Still works but emits a warning.

Lazygit Integration

Run the setup script to add a keybinding (Ctrl+G / Cmd+G on macOS) that generates commit messages directly in lazygit:

./scripts/setup-lazygit.sh

Manual setup

Add to your lazygit config.yml (~/Library/Application Support/lazygit/config.yml on macOS, ~/.config/lazygit/config.yml on Linux):

customCommands:
  - key: <c-g>
    prompts:
      - type: input
        title: Additional Instructions (optional)
        key: Instructions
        initialValue: ""
      - type: menuFromCommand
        title: AI Commit Messages
        key: Msg
        command: 'rs-git-msg -n 5 {{if .Form.Instructions}}-i "{{.Form.Instructions}}"{{end}}'
    command: git commit -m "{{.Form.Msg}}"
    context: 'files'
    description: 'Generate commit message using rs-git-msg'
    loadingText: 'Generating commit messages...'
    stream: false

Uninstallation

rm ~/.local/bin/rs-git-msg      # or: sudo rm /usr/local/bin/rs-git-msg
rm -rf ~/.config/rs-git-msg     # optional: remove config

Or use the uninstall script: ./scripts/uninstall.sh

Contributing

Contributions are welcome! See CONTRIBUTING.md for development setup, testing, and submission guidelines.

About

AI-powered git commit message generator that analyzes staged changes.

Topics

Resources

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors