Skip to content

Instantly share code, notes, and snippets.

@taupecat
Last active December 31, 2016 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taupecat/926ecf316b9ecd0c424e03dd94da9255 to your computer and use it in GitHub Desktop.
Save taupecat/926ecf316b9ecd0c424e03dd94da9255 to your computer and use it in GitHub Desktop.
Automattically prepend the branch name to the git commit. Useful for integrations with JIRA, Slack, etc. When working with git flow, this will ignore the word before the slash (feature/hotfix/release).
#!/bin/sh
#
# Prepend the Branch Name to the commit
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD | sed 's/.*\///')
if [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "master" ] && [ "$BRANCH_NAME" != "develop" ]; 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