{"id":1250,"date":"2025-03-21T09:00:38","date_gmt":"2025-03-21T10:00:38","guid":{"rendered":"http:\/\/www.diveintoaccessibility.com\/?p=1250"},"modified":"2025-04-30T10:31:39","modified_gmt":"2025-04-30T10:31:39","slug":"write-clear-git-commit-messages-with-ai-and-commitizen","status":"publish","type":"post","link":"http:\/\/www.diveintoaccessibility.com\/index.php\/2025\/03\/21\/write-clear-git-commit-messages-with-ai-and-commitizen\/","title":{"rendered":"Write Clear Git Commit Messages with AI and Commitizen"},"content":{"rendered":"
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\u2019ve all seen commits like \u201cfixed stuff\u201d or \u201cupdate code\u201d that leave everyone guessing what actually changed.<\/p>\n
That\u2019s where Commitizen<\/a><\/strong> comes in. It\u2019s 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 \u201ccommit language\u201d.<\/p>\n In this article, we\u2019ll explore how Commitizen enforces good commit habits. We\u2019ll also take it a step further by pairing Commitizen with an AI-powered assistant<\/a>, which will turn it from a chore into a seamless part of your workflow.<\/p>\n To get started, we need to install cz-git<\/a> with NPM:<\/p>\n This will allow us to access the cz CLI tool globally, in any directory.<\/p>\n Then, we need to add and set the Commitizen config file. We can run:<\/p>\n cz-git<\/strong> supports both OpenAI API, and Ollama. In this case, we are going to use Ollama for a few reasons:<\/p>\n To create a Git commit message, it\u2019s generally recommended to use a model with code-understanding capability, such as qwen2.5-coder<\/a>, starcoder2<\/a>.<\/p>\n Feel free to use any of these models. For the example in this article, we\u2019ll be using 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\u2019d suggest downloading the smaller model, such as the 1.5B which is only around ~900MB. You can download this model with the following command:<\/p>\n After the download is complete, we need to update the configuration at To generate the commit message, make sure that we\u2019ve already staged the files. Otherwise, run You will need to select the type of changes. Is it a feature, a fix, or a chore update?<\/p>\n Once you select one, it will start generating the message.<\/p>\n If you\u2019re satisfied with the generated message, select It\u2019s pretty amazing how far AI has advanced in the last couple of years. It\u2019s becoming more accessible and affordable. We can use it to make tasks that once felt like a chore much easier and quicker to do.<\/p>\n I highly recommend you give it a try!<\/p>\n The post Write Clear Git Commit Messages with AI and Commitizen<\/a> appeared first on Hongkiat<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":" 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 […]<\/p>\n","protected":false},"author":1,"featured_media":1252,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts\/1250"}],"collection":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/comments?post=1250"}],"version-history":[{"count":3,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts\/1250\/revisions"}],"predecessor-version":[{"id":1255,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/posts\/1250\/revisions\/1255"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/media\/1252"}],"wp:attachment":[{"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/media?parent=1250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/categories?post=1250"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.diveintoaccessibility.com\/index.php\/wp-json\/wp\/v2\/tags?post=1250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Installation<\/h2>\n
\r\nnpm i -g commitizen cz-git\r\n<\/pre>\n
Configuration<\/h2>\n
\r\necho '{ \"path\": \"cz-git\" }' > ~\/.czrc\r\n<\/pre>\n
AI Config<\/h3>\n
\n
qwen2.5-coder<\/code>. Run the following command to download it.<\/p>\n
\r\nollama pull qwen2.5-coder\r\n<\/pre>\n
\r\nollama pull qwen2.5-coder:1.5b\r\n<\/pre>\n
~\/.czrc<\/code> 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.<\/p>\n
\r\n{\r\n \"$schema\": \"https:\/\/raw.githubusercontent.com\/Zhengqbbb\/cz-git\/refs\/heads\/main\/docs\/public\/schema\/cz-git.json\",\r\n \"path\": \"cz-git\",\r\n \"aiModel\": \"qwen2.5-coder\",\r\n \"apiEndpoint\":\"http:\/\/127.0.0.1:11434\/v1\",\r\n \"openAIToken\":\" \",\r\n \"useAI\": true\r\n}\r\n<\/pre>\n
Generate Commit Message<\/h2>\n
git add<\/code>. Then, you can simply run the following command:<\/p>\n
\r\nczg\r\n<\/pre>\n
<\/figure>\n
<\/figure>\n
Y<\/code> and hit Enter<\/kbd>. It will immediately create and push the commit for you.<\/p>\n
Final Thought<\/h2>\n