Skip to content

Instantly share code, notes, and snippets.

@dominiceden
Last active December 22, 2018 18:38
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 dominiceden/eaf9c5fc18260c95c8ed7b0a462e9810 to your computer and use it in GitHub Desktop.
Save dominiceden/eaf9c5fc18260c95c8ed7b0a462e9810 to your computer and use it in GitHub Desktop.
Automatically add branch name to every Git commit message
#!/bin/sh
#
# Automatically adds branch name to every commit message.
# e.g. [feature/some-feature] Commit message here
# Remove .sh extension when copying into your .git/hooks folder.
#
NAME=$(git branch | grep '*' | sed 's/* //')
echo "[$NAME]"' '$(cat "$1") > "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment