Skip to content

Instantly share code, notes, and snippets.

@klopp
Created March 25, 2020 20:59
Show Gist options
  • Save klopp/c37c1de5ae8a93d896494b0f050d7f81 to your computer and use it in GitHub Desktop.
Save klopp/c37c1de5ae8a93d896494b0f050d7f81 to your computer and use it in GitHub Desktop.
Add branch name to commit message
#!/bin/bash
NAME=$(git branch | grep '' | sed 's/ //')
MSG=$(head -n 1 "$1");
if [[ ! "$MSG" =~ "$NAME" ]]; then
echo "$NAME"' '"$(cat $1)" > "$1"
DESCRIPTION=$(git config branch."$NAME".description)
if [ -n "$DESCRIPTION" ]; then
echo "" >> "$1"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment