In my company we use Jira, and our branch's name follows this convention CODE-123-Something-descriptive-after And I want to have that code automatically whenever I commit with message. So, you can exclude the grep part if you want to get the whole branch name
Copy the script below, name it prepare-commit-msg
and put it under git/hooks
folder. Make sure you make it executable by chmod 755 your/path/prepare-commit-msg
#!/bin/bash
if [ -z "$BRANCHES_TO_SKIP" ]; then