Skip to content

Instantly share code, notes, and snippets.

@jmgarnier
Last active December 16, 2015 12:29
Show Gist options
  • Save jmgarnier/5434874 to your computer and use it in GitHub Desktop.
Save jmgarnier/5434874 to your computer and use it in GitHub Desktop.
Tired of typing the ticket number at the beginning of each commit msg? Git hooks to the rescue! From your current git project, edit the .git/hooks/prepare-commit-msg
#!/bin/sh
project="VCORE-"
ticket=$(git symbolic-ref HEAD | awk -F- '/VCORE-(.*)-/ {print $2}')
if [ -n "$ticket" ]; then
TEMP=`mktemp /tmp/commitmsg-XXXXX`
(echo "$project$ticket - "; cat $1) > $TEMP
cat $TEMP > $1
fi
@marcelmorgan
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment