Skip to main content

Generate Git commit messages using local LLMs via Ollama

Project description

ollama-commit

PyPI version CI Python versions License: MIT

Generate Git commit messages using local LLMs via Ollama — no cloud, no API keys, no data leaving your machine.

$ git add src/auth.py
$ ollama-commit

Staged files (1): src/auth.py
Querying mistral via http://localhost:11434…

╭─ Suggested commit message ──────────────────────────────╮
│ feat(auth): add JWT refresh token rotation               │
╰──────────────────────────────────────────────────────────╯

Commit with this message? [Y/n]:

Features

  • Local-first — uses Ollama, everything runs on your machine
  • Conventional Commits — output follows the Conventional Commits spec
  • Multiple suggestions — get up to 5 variants and pick the best one (-n 3)
  • Context hints — give the model a nudge (--hint "refactoring auth")
  • Git hook — auto-fill the commit message editor on every git commit
  • Interactive or silent--yes flag for scripting and CI

Requirements

  • Python ≥ 3.10
  • Ollama running locally (ollama serve)
  • At least one model pulled: ollama pull mistral

Installation

pip install ollama-commit

Or for development:

git clone https://github.com/dennisreichenberg/ollama-commit
cd ollama-commit
pip install -e ".[dev]"

Usage

Basic

# Stage your changes, then:
git add .
ollama-commit

Get multiple suggestions

ollama-commit --count 3

Use a different model

ollama-commit --model llama3
ollama-commit --model codellama

Add a context hint

ollama-commit --hint "this fixes the login redirect bug"

Auto-commit without prompting

ollama-commit --yes

Dry run (print only, do not commit)

ollama-commit --dry-run

List available models

ollama-commit models

Git hook (auto-fill on git commit)

# Install hook in current repo
ollama-commit install-hook

# Remove hook
ollama-commit uninstall-hook

Options

Option Short Default Description
--model -m mistral Ollama model to use
--host http://localhost:11434 Ollama base URL
--count -n 1 Number of suggestions (1–5)
--hint -h Optional hint for the model
--yes -y Auto-accept and commit
--dry-run Print message, don't commit

Recommended models

Model Size Notes
mistral 4.1 GB Best quality/speed for commits
llama3 4.7 GB Excellent for English commits
codellama 3.8 GB Code-focused, good for technical diffs
phi3 2.2 GB Fast, good quality for small models
qwen2.5-coder 4.7 GB Strong code understanding

How it works

  1. Reads git diff --staged from the current repository
  2. Sends the diff (and optional hint) to your local Ollama model
  3. Receives a Conventional Commit formatted message
  4. Optionally commits with that message after confirmation

Configuration via environment variables

export OLLAMA_COMMIT_MODEL=llama3
export OLLAMA_COMMIT_HOST=http://localhost:11434

(Env var support coming in v0.2)

License

MIT — see LICENSE

Contributing

PRs welcome! See CONTRIBUTING.md for guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ollama_commit-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ollama_commit-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file ollama_commit-0.1.0.tar.gz.

File metadata

  • Download URL: ollama_commit-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ollama_commit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e225586bb2d4cda5a04123d9ac7a1e828f5e1eac799bf3cf8aaa1a2854ee438
MD5 164609f961283fd75fe1ea5ce5e01bd2
BLAKE2b-256 2afbdc96de215c56b1b98d83b3093eaa780f3bee6283d9748d3b0a01ddbcf67f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ollama_commit-0.1.0.tar.gz:

Publisher: ci.yml on dennisreichenberg/ollama-commit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ollama_commit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ollama_commit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ollama_commit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c5c2da3372d730893e28c688580249d0ff13deb285e88c4188862991c91c1d3
MD5 c1473c16cef9b6ab4553aed84b9f6030
BLAKE2b-256 539f7f3b1c7a6f1e862c8b5bf53502e699b6902085f0edd076f8a14b11d0aaf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for ollama_commit-0.1.0-py3-none-any.whl:

Publisher: ci.yml on dennisreichenberg/ollama-commit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page