We are using Redmine for tracking our programming tasks in my current project. Like most other ticketing systems, it has the ability to link commits in your source code repositories to a ticket when the commit message refers the ticket number.
1 2 3
I became tired of adding the ticket number manually to each commit message. Fortunately, git can add the number by itself with the help of a little hook and a naming convention for your feature branches.
Your feature branch name should include the ticket number like so:
Now create the file
.git/hooks/commit-msg in your local repository with the following
1 2 3 4 5 6
This extracts the ticket number from the branch name. The ticket number is then appended to your commit message on each commit when git executes the hook.