Skip to content

Instantly share code, notes, and snippets.

@techjacker
Last active March 18, 2016 14:56
Show Gist options
  • Save techjacker/2fee40d6d0d9fc4e9ade to your computer and use it in GitHub Desktop.
Save techjacker/2fee40d6d0d9fc4e9ade to your computer and use it in GitHub Desktop.
Prepend feature branch name to commit message
#!/bin/bash
#################################################################
#
# prepend feature branch name to the commit message
# eg feature/MT-3453 -> 'MT-3453 my brilliant new feature'
#
# 1. save to .git/hooks/prepare-commit-msg
# 2. chmod +x .git/hooks/prepare-commit-msg
#
#################################################################
BRANCH_STR=$(git status | sed -n 1p)
if echo "$BRANCH_STR" | grep -q 'feature'; then
echo "${BRANCH_STR/On\ branch\ feature\//}: $(cat $1)" > $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment