Created
October 1, 2020 23:58
-
-
Save rkmaier/222e2789290b155c0763e4cd3b9ae974 to your computer and use it in GitHub Desktop.
Git HooK - Prepend Branch name to commit messages
This file contains 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 | |
# Prepend Branch name to commit messages | |
# Succeed on all merge messages, as evidenced by MERGE_MSG existing | |
[ -f $GIT_DIR/MERGE_MSG ] && exit 0 | |
# Get branch name and description | |
NAME=$(git branch | grep '*' | sed 's/* //') | |
DESCRIPTION=$(git config branch."$NAME".description) | |
if [ "$NAME" != "(no branch)" ]; then | |
# Append branch name and optional description to COMMIT_MSG | |
# For info on parameters to githooks, run: man githooks | |
echo "$NAME - $(cat $1)" >$1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment