Github issue number and commit message
I use Github Issues and often i forget to add issue number to commit message. Usually i prepend message with #some-number. i.e. current branch '308-context-help' and commit message 'fix bug' will result in '#308 fix bug').
So i decide to use git's commit-msg hook for that task:
#!/bin/sh
if [ "$NOPREFIX" ]; then
exit 0
fi
number=$(git branch | grep '*' | sed 's/* //' | cut -d'-' -f 1)
if [[ "$number" =~ ^[0-9]+$ ]] ; then
echo '#'"$number"' '$(cat "$1") > "$1"
fi
Just put that code to .git/hooks/commit-msg
and you're done.
Written by Dmitry Novotochinov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
khasinski
591.1K
dmichaelavila
500.4K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#