gcm
is a lightweight function that automatically generates commit messages using an LLM models with ollama
. It provides an interactive prompt to accept, edit, regenerate, or cancel the commit message. You can also specify a different model for message generation. Inspired by Andrej Karpathy's gist snippet.
gcm
requires Ollama to generate commit messages. Install it by following the instructions on the official website:
curl -fsSL https://ollama.ai/install.sh | sh
Run the following script to install gcm
:
# Clone the repository
git clone https://github.com/umutkavakli/gcm.git
cd gcm
# Run the install script
chmod +x install.sh
./install.sh
This will:
- Copy required files to
/usr/local/share/gcm/
- Set up an alias in
~/.bashrc
for easy access
Simply stage your changes and run:
gcm
This will:
- Generate a commit message based on staged changes
- Show an interactive prompt with options:
(a)ccept
: Use the generated commit message(e)dit
: Enter a custom message(r)egenerate
: Generate a new message(c)ancel
: Exit without committing
To use a different model for commit message generation:
gcm -m model_name
This will:
- Update
Modelfile
to use the specified model - Recreate the AI model with
ollama create
To see available options, run:
gcm -h
1. gcm: command not found
?
Ensure that your shell is sourcing the alias. Run:
source ~/.bashrc
2. AI model fails to generate messages?
Check if ollama
is installed and working properly:
ollama list