Skip to content

Instantly share code, notes, and snippets.

View alexshevch's full-sized avatar
🍁

Alex Shevchenko alexshevch

🍁
  • Vancouver, Canada
View GitHub Profile
@alexshevch
alexshevch / prepare-commit-msg.sh
Created February 14, 2018 16:36
Automatically prepend git commit message with a branch name
#!/bin/sh
#
# Hook script to prepend the commit log message with a branch name
# Prepend the name of the branch only if:
# - branch name starts with one of the options in $BRANCH_STARTSWITH
# - branch name has not been manually prepended in the commit message
BRANCH_STARTSWITH=(dev- WIP XYZ-)
BRANCH_NAME=$(git symbolic-ref --short HEAD)
COMMIT_MESSAGE=$(cat $1)