Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GCM - AI-Powered Git Commit Message Generator

gcm is a command-line tool that generates meaningful Git commit messages with appropriate emojis based on your Git diff, powered by local LLMs through Ollama.

Description

This tool pipes your Git diff into an Ollama instance running locally to generate semantically relevant commit messages that follow conventional commit formats with emoji prefixes. It's perfect for developers who want consistent, meaningful commit messages without the mental overhead of crafting them each time. GCM - AI-Powered Git Commit Message Generator - visual selection

Features

  • Generates commit messages with appropriate emoji prefixes
  • Analyzes Git diff content to create contextual commits
  • Follows conventional commit standards
  • Runs completely locally (no data sent to external APIs)
  • Fast and lightweight

Prerequisites

  • Rust (for building)
  • Ollama running locally
  • A compatible language model (default: "gemma3")

Installation

From Source

git clone https://github.com/vinodnimbalkar/gcm.git
cd gcm
cargo install --path .

From Release

This one-line installation does not support every OS

curl -sL "https://github.com/vinodnimbalkar/gcm/releases/download/v1.0.2/gcm" | sudo tee ~/.local/bin/gcm >/dev/null && sudo chmod +x ~/.local/bin/gcm

Using the Docker Image

You can directly use the pre-built Docker image from Docker Hub:

docker pull vinodnimbalkar/gcm:latest

Using with Gemini API via Docker

git diff | docker run -i --rm -e GEMINI_API_KEY=your_api_key_here vinodnimbalkar/gcm:latest

Creating a Shell Alias for Docker

# Add to .bashrc, .zshrc, etc.
alias docker-gcm='commit_message=$(git diff --staged | docker run -i --rm -e GEMINI_API_KEY=your_api_key_here vinodnimbalkar/gcm:latest); git commit -m "$(echo "$commit_message" | head -n 1)" -m "$(echo "$commit_message" | tail -n +2)"'

Usage

Simply pipe your Git diff to the tool:

git diff | gcm

Or for staged changes:

git diff --staged | gcm

Then use the generated message to commit:

git commit -m "$(git diff --staged | gcm)"

For convenience, you might want to add an alias to your shell configuration:

# Add to .bashrc, .zshrc, etc.
alias gcm='commit_message=$(git diff --staged | gcm); git commit -m "$(echo "$commit_message" | head -n 1)" -m "$(echo "$commit_message" | tail -n +2)"'

LLM Service Configuration

The tool supports two LLM services:

1. Ollama (Default, Local)

If no Gemini API key is set, gcm will use Ollama by default. Ollama must be installed and running locally.

You can configure the Ollama model using an environment variable:

export OLLAMA_MODEL=gemma3  # Default is "gemma3"

2. Gemini (Cloud API)

To use Google's Gemini API:

  1. Obtain a Gemini API key from Google AI Studio
  2. Set the API key as an environment variable:
export GEMINI_API_KEY=your_api_key_here

gcm will automatically use Gemini when the GEMINI_API_KEY environment variable is set.

Commit Message Format

<type>: <emoji><message>
<detailed description>

Example:

feat: ✨Add user authentication
Implement OAuth2 login flow with Google and GitHub providers

Supported Commit Types and Emojis

Type Emoji
Initial commit 🎉 :tada:
Version tag 🔖 :bookmark:
New feature :sparkles:
Bugfix 🐛 :bug:
Metadata 📇 :card_index:
Documentation 📚 :books:
Documenting source code 💡 :bulb:
Performance 🐎 :racehorse:
Cosmetic 💄 :lipstick:
Tests 🚨 :rotating_light:
Adding a test :white_check_mark:
Make a test pass ✔️ :heavy_check_mark:
General update :zap:
Improve format/structure 🎨 :art:
Refactor code 🔨 :hammer:
Removing code/files 🔥 :fire:
Continuous Integration 💚 :green_heart:
Security 🔒 :lock:
Upgrading dependencies ⬆️ :arrow_up:
Downgrading dependencies ⬇️ :arrow_down:
Lint 👕 :shirt:
Translation 👽 :alien:
Text ✏️ :pencil:
Critical hotfix 🚑 :ambulance:
Deploying stuff 🚀 :rocket:
Fixing on MacOS 🍎 :apple:
Fixing on Linux 🐧 :penguin:
Fixing on Windows 🏁 :checkered_flag:
Work in progress 🚧 :construction:
Adding CI build system 👷 :construction_worker:
Analytics or tracking code 📈 :chart_with_upwards_trend:
Removing a dependency :heavy_minus_sign:
Adding a dependency :heavy_plus_sign:
Docker 🐳 :whale:
Configuration files 🔧 :wrench:
Package.json in JS 📦 :package:
Merging branches 🔀 :twisted_rightwards_arrows:
Bad code / needs improvement 💩 :hankey:
Reverting changes :rewind:
Breaking changes 💥 :boom:
Code review changes 👌 :ok_hand:
Accessibility :wheelchair:
Move/rename repository 🚚 :truck:

Configuration

The tool currently uses "gemma3" as the default model. You can modify the source code to use different Ollama models.

License

MIT License

Contributing

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

About

`gcm` is a command-line tool leveraging local LLMs via Ollama OR Google's Gemini API to generate Git commit messages with relevant emojis based on the Git diff.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages