Last active
December 3, 2020 01:14
-
-
Save vaporwavie/4de2ee1fc151a80fe8730a3c9434f7a0 to your computer and use it in GitHub Desktop.
Git Hook that appends your branch name within the commit message.
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 | |
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *' | sed 's:.*/::') | |
if [ -n "$BRANCH_NAME" ]; then | |
echo "$BRANCH_NAME: $(cat $1)" > $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
.git/hooks
directory, renameprepare-commit-msg.sample
toprepare-commit-msg
prepare-commit-msg
and delete all of its contentPossible scenarios:
Be aware that this script expects this pattern: [BRANCH_TYPE]/[TICKET], where only [TICKET] will be appended.
git commit
will output "BRANCH_NAME: [whitespace]" inside your git preferred editorgit commit -[a]m "YOUR_MESSAGE"
will output "BRANCH_NAME: YOUR_MESSAGE"