Last active
May 27, 2017 17:35
-
-
Save witooh/8d28b5ffff6909cfffda8a3bd44171a1 to your computer and use it in GitHub Desktop.
git commit template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# git commit template | |
gitPath=$(git rev-parse --show-toplevel) | |
if [ -z $gitPath ] | |
then | |
exit $? | |
fi | |
gitBranch=$(git symbolic-ref --short HEAD | cut -d"-" -f1 -f2) | |
case $1 in | |
-r) | |
cp /dev/null ${gitPath}/.git/commit_msg_template.txt | |
echo "Remove git commit template." | |
exit 0 | |
;; | |
*) | |
git config --local commit.template $gitPath/.git/commit_msg_template.txt | |
cp /dev/null ${gitPath}/.git/commit_msg_template.txt | |
if [ ! -z $1 ] | |
then | |
gitBranch=$1 | |
fi | |
echo $gitBranch >> ${gitPath}/.git/commit_msg_template.txt | |
echo "Add \"$gitBranch\" in git commit template." | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment