Introduction
If you read it right, Iām never writing a commit again, well, thatās not entirely true, I am going to write it, but Iām going to worry less about writing it⦠Iām going to do them in a lighter, more carefree way.
Donāt know what I mean? Well, Iām going to go from this
to this

without doing anything, just writing something basic like āchangesā or not even that.
The importance of a good commit message
Committing is something very simple that we do constantly every day, but do we give it the relevance it deserves? Let me talk to you about the importance of commits,
You might think itās no big deal, but I have to tell you that a good commit message is essential to keep a project organized and understandable. We all know that in software development a large part of time is spent on maintaining and reading code.
Imagine how much that task can be facilitated with clear and descriptive commit messages.
In addition, in group work environments, where there is more than one person, a good commit history is like an open book of the projectās evolution. And well, even if you are programming alone. All this helps you understand why certain changes were made and also facilitates teamwork.
My solution
I donāt think programmers write bad commits or that there is a problem at a general level, but I do understand that often, we are so focused on the code that we donāt stop to write a perfect commit message. Either because we want to upload it quickly to check that the pipeline passes or for any other reason that distracts us when committing.
Thatās why I created a script, super basic, that every time you make a commit, passes your message through the free Gemini API and rewrites it following the rules you specify, that is, a custom prompt.
The script uses a Python dependency that fetches Gemini in the background, it is easy to use because it only needs your Gemini API key, but the code could be modified to fetch your favorite API of any LLM.
The āmagicā for it to execute every time we commit is found in the git hooks, you donāt have to worry about that, since I left another script in the code that adds the necessary hook to execute our code to the projects in a directory you specify. Apart from that, it modifies the configuration so that in new projects this applies by default, so it would never be necessary to execute it again.
Customization
And best of all, this system is fully configurable. You can adjust the prompt to follow your companyās standards, your teamās or simply the ones you prefer. For example, I have set it to follow Conventional Commits standards, but you can literally tell it to reply with insults or a very unprofessional phrase.
In addition, I have added a flag that is very easy to modify in the script in case you also want the modified code (i.e. the git diff) to be passed to the API. This is useful if you want the commit message to have context about the changes made. For example, it could summarize the most important changes or highlight a key function you have implemented.
Of course, I put it in a flag in the code because I understand that due to privacy or security issues it is not possible to send the code to an external API. No problem, just donāt activate the flag and the script will only work with the message you provide, without sharing any code snippets.
Although well, according to Googleās privacy policies, Gemini does not use conversation data to train its models, but thatās up to you, Iām not getting into that.

I leave you more info about that here
https://cloud.google.com/vertex-ai/generative-ai/docs/data-governance?hl=es-419
https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/multimodal-faqs?hl=es-419
And what do I gain from all this?
Automating commit message generation not only saves you time, but also reduces cognitive load. Our brain has a limited capacity to make decisions and concentrate on complex tasks. By delegating repetitive and less critical tasks, such as polishing commit messages, we free up mental resources for what really matters: solving problems and writing quality code.
Nah, actually I donāt know, I was just bored and it seemed entertaining and sometimes Iām lazy to commit properly⦠thatās all.
Code
š https://github.com/edunavajas/git-commit-enhancer
Iām not going to go into low-level detail about what you have to do to install it because it says everything in the README, but basically, for the script to work you must first install the dependencies which is done from the file called dependencies, itās obvious right? Well unless you have Windows then you will have to follow some manual steps⦠sorry, itās not my fault you program in Windows⦠And finally I have another Python script there for the āSetupā so you can indicate a folder of existing repositories so that the hook we talked about before is applied to them.
I donāt know if it will be useful to anyone, but it helps me a lot in my day to day!



What do you think?
Leave your opinion, question or suggestion. Comments are synced with GitHub Discussions .