Created
July 22, 2019 06:49
-
-
Save MatteoGioioso/615596ca1ad11c4e08919acf2473ec1f to your computer and use it in GitHub Desktop.
How to automatically prepend git commit with a branch number tag
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/bash | |
#Does not work if executed as sh | |
#Copy this commit script into prepare-commit-msg | |
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *') | |
IFS='-' read -r -a array <<< "$BRANCH_NAME" | |
if [ -n "$BRANCH_NAME" ]; then | |
echo " (#$array) $(cat $1)" > $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment