Skip to content

Instantly share code, notes, and snippets.

@pixmin
Last active July 5, 2018 08:28
Show Gist options
  • Select an option

  • Save pixmin/ed43f009d7bce1c45644f03a9cde4bce to your computer and use it in GitHub Desktop.

Select an option

Save pixmin/ed43f009d7bce1c45644f03a9cde4bce to your computer and use it in GitHub Desktop.
GIT Prepare Commit message with part of branch name
#!/bin/sh
#
# Automatically adds Redmine task reference to every commit message.
# Ex branch: dev-12345
# Will result in:
# Refs #12345 [rest of commit message]
#
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME=$(echo $BRANCH_NAME | sed -e 's/dev-//g') # Remove "dev-" part
BRANCH_NAME="${BRANCH_NAME##*/}"
sed -i.bak -e "1s/^/Refs #$BRANCH_NAME /" $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment