Skip to content

Instantly share code, notes, and snippets.

@mattmcla
Last active December 14, 2015 06:19
Show Gist options
  • Save mattmcla/5041586 to your computer and use it in GitHub Desktop.
Save mattmcla/5041586 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Automatically adds branch name 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
@dropwhile
Copy link

echo "[$NAME] $(cat "$foo" | sed '/^#.*/d')" > "$foo"

:P

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