DEV Community

Cover image for Automating the Git commit message prefix
Filip Iulian Pacurar
Filip Iulian Pacurar

Posted on • Originally published at

Automating the Git commit message prefix

If you’re a programmer you probably love automating the daily tasks you do daily, don’t you? Well, if you don’t you probably should.

The current project I work on has a specific Git Branching model that follows the Jira tasks number. In a nutshell, here are the requirements: when I tackle a story/feature task, it has a number, let’s say TASK-1. You move the ticket into in-progress and you also create a first sub-task called “Implement” or “Fix” or something similar.

If you’re like me and like to see the process visually, here’s how it looks:

Image description

In addition to the branching model above, the commit messages must follow the following rule for the prefix: MainTask/SubTask: [commit message]. For example for the task in the flow above, the commit message can be TASK-1/TASK-2: Write the first draft.

For me, this was the most cumbersome thing, mainly because I want to commit often, not have a single commit with all the finished code, so whenever I did a commit I had to look up the story number and the sub-task I am working on.

Let’s see how we can automate this prefix.

Part 1 – Git Hooks and config

Git is very extendible: you can have various custom Key-Value configurations for each local repository or for the global Git system itself. We’re gonna be using some custom Git configurations to suit our automation.

Read the rest of the tutorial here.

Top comments (0)