Skip to content

Instantly share code, notes, and snippets.

@micahrcorn
Created February 9, 2016 17:02
Show Gist options
  • Save micahrcorn/75bffbbf0405a9837664 to your computer and use it in GitHub Desktop.
Save micahrcorn/75bffbbf0405a9837664 to your computer and use it in GitHub Desktop.
sample prepare-commit-msg
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
#
NAME=$(git branch | grep '*' | sed 's/* //')
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$TEXT" ]
then
echo "$NAME"' '$(cat "$1" | sed '/^#.*/d') > "$1"
else
echo "Aborting commit due to empty commit message."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment