Commet creates commit messages using Ollama. There are plenty of tools out there that do this but I was looking for something that does not rely on a pre-commit hook or similar. Instead I wanted just an alternative CLI command to git commit
which I can use across my projects and integrates into my current workflow.
Commet does three things using your local git installation and Ollama:
- Get the current diff of the staged files (e.g.
git diff --cached
) - Send the diff with a prompt asking for a commit message to Ollama
- Commit the changes and opening the editor to potentially edit the message (
git commit -m <the message> -e
)
brew tap gcascio/commet
brew install commet
Download the pre-compiled binaries from the releases page and copy them to the desired location.
- Local git installation
- Access to the ollama API (by default at http://localhost:11434) with a model of choice (default: mistral)
commet [flags]
-a, --all Commit all changed files i.e. 'git commit -a'
-h, --help help for commet
--llm string URL to LLM API i.e. Ollama, defaults to: http://localhost:11434/api/chat
-m, --model string LLM model to be used, defaults to: mistral
For persistent configurations commet can be configured with a .commet.yaml file in the home directory. E.g.
llm: https://mydomain.com
model: mistral
Commet works best with small to medium sized changes. Trying to generate a commit message for a large change over multiple files usually results in unsatisfying results. In these cases it is recommended to split the changes into multiple smaller commits.
As a starting point, the prompt to create the commit messages is mostly taken from opencommit.