Created
July 13, 2017 22:41
-
-
Save dominic-rossi/74e9ca9d48988117f900c38eaab1ed86 to your computer and use it in GitHub Desktop.
Add the current branch name to the beginning of commit messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
branch_name=$(git symbolic-ref -q HEAD) | |
branch_name=${branch_name##refs/heads/} | |
branch_name=${branch_name:-HEAD} | |
firstLine=$(head -n1 $1) | |
if [ -z "$firstLine" ] ;then #Check that this is not an amend by checking that the first line is empty | |
sed -i "1s@^@$branch_name: \n@" $1 #Insert branch name at the start of the commit message file | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment