Photo by Yancy Min on Unsplash If you're reading this chances are that you're already aware of what git is and you also work with any ticket-based software, like Jira. In this article, I'm going to show you how automatically prepend the ticket ID you're working on to your commit message, assuming that you're using you're branch names similar to . feature/ABC-1234-Feature-testing To achieve this, you're going to use . git hooks Git hooks According to : Git Hooks Git hooks are scripts that Git executes before or after events such as: commit, push, and receive. Git hooks are a built-in feature - no need to download anything. Git hooks are run locally. Now that you know what you need, just create a new file under folder. Name it . .git/hooks prepare-commit-msg Copy the code below and paste it into your newly created file. [ -z ]; BRANCHES_TO_IGNORE=(master develop staging ) BRANCH_NAME=$(git symbolic-ref --short HEAD) BRANCH_IGNORED=$( | grep -c ) TRIMMED=$( | sed -E -e -e ) [ -n ] && ! [[ -eq 1 ]]; sed -i.bak -e #!/bin/bash # List the branches that don't apply bellow if " " $BRANCHES_TO_IGNORE then test fi # Pick the current branch name and check if it is excluded printf "%s\n" " " ${BRANCHES_TO_IGNORE[@]} "^ $" $BRANCH_NAME # Remove the unnecessary parts echo $BRANCH_NAME 's:^(\w+)\/([^-]*-[^-]*)-.*:\2:' 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' # If it isn't excluded, prepend the part that interests us to the given commit message if " " $BRANCH_NAME $BRANCH_IGNORED then "1s/^/ - /" $TRIMMED $1 fi After the creation of the file, you'll need to give it its proper permissions. This can be achieved by executing . chmod +x prepare-commit-msg If you want to see it in action just make a new commit and type any message you want. You should see now, given the branch name above, something like: commit 976f4354779a824e5edfd851857b26c9bcfd3e14 (feature/ABC-1234-Feature-testing) Author: Rafael <email@example.com> Date: Tue Jul 23 17:35:25 2019 +0100 ABC-1234 - This is a testing message Apply your changes globally Now that I've shown you how to improve your commit messages you'll want to apply the condition to every other repo in your machine, right? I'm going to show you how to achieve it. The first step is to create a folder that's going to contain all of your hooks. I'm using this I've created but you can use whichever you prefer. After having your own folder you execute the following command: repo git config --global init.templatedir '~/projects/git-hooks-templates' Within you should have another folder named , this is where we're going to place our git hooks. hooks Now that the folder structure is correct you can copy the file created above into the, in this example (yours might differ) directory. The command to execute after is: ~/projects/git-hooks-templates chmod a+x ~/projects/git-hooks-templates/hooks/prepare-commit-msg Now you have everything set up. Every time that you create or clone new repositories your commit messages will be appended with the ticket ID based on the branch that you're working on.