Write Clear Git Commit Messages with AI and Commitizen
Writing clear, consistent Git commit messages can be a struggle, especially in a team setup where there multiple developers writing code and contributing to the project. We’ve all seen commits like “fixed stuff” or “update code” that leave everyone guessing what actually changed.
That’s where Commitizen comes in. It’s a tool designed to solve this problem by providing a shared format for writing structured commit messages. Think of it as a friendly guide that ensures everyone in your team speaks the same “commit language”.
In this article, we’ll explore how Commitizen enforces good commit habits. We’ll also take it a step further by pairing Commitizen with an AI-powered assistant, which will turn it from a chore into a seamless part of your workflow.
Installation
To get started, we need to install cz-git with NPM:
npm i -g commitizen cz-git
This will allow us to access the cz CLI tool globally, in any directory.
Configuration
Then, we need to add and set the Commitizen config file. We can run:
echo '{ "path": "cz-git" }' > ~/.czrc
AI Config
cz-git supports both OpenAI API, and Ollama. In this case, we are going to use Ollama for a few reasons:
- Plenty of model options.
- It runs locally.
- It’s free.
To create a Git commit message, it’s generally recommended to use a model with code-understanding capability, such as qwen2.5-coder, starcoder2.
Feel free to use any of these models. For the example in this article, we’ll be using qwen2.5-coder
. Run the following command to download it.
ollama pull qwen2.5-coder
Keep in mind that this is going to download the default model which comes with 7B parameters and 4.5GB. If your computer has fewer resources, I’d suggest downloading the smaller model, such as the 1.5B which is only around ~900MB. You can download this model with the following command:
ollama pull qwen2.5-coder:1.5b
After the download is complete, we need to update the configuration at ~/.czrc
to specify that we use AI as well as the model to generate the commit message, the endpoint, and the token. Since we use Ollama, we can leave the token empty as it does not require one.
{ "$schema": "https://raw.githubusercontent.com/Zhengqbbb/cz-git/refs/heads/main/docs/public/schema/cz-git.json", "path": "cz-git", "aiModel": "qwen2.5-coder", "apiEndpoint":"http://127.0.0.1:11434/v1", "openAIToken":" ", "useAI": true }
Generate Commit Message
To generate the commit message, make sure that we’ve already staged the files. Otherwise, run git add
. Then, you can simply run the following command:
czg
You will need to select the type of changes. Is it a feature, a fix, or a chore update?

Once you select one, it will start generating the message.

If you’re satisfied with the generated message, select Y
and hit Enter. It will immediately create and push the commit for you.
Final Thought
It’s pretty amazing how far AI has advanced in the last couple of years. It’s becoming more accessible and affordable. We can use it to make tasks that once felt like a chore much easier and quicker to do.
I highly recommend you give it a try!