Skip to content

Instantly share code, notes, and snippets.

View boschni's full-sized avatar

Niek Bosch boschni

  • Niek Bosch Consultancy
View GitHub Profile
@boschni
boschni / commit-msg
Last active January 11, 2017 10:29
Git commit hook to automatically add branch name to every commit message. Put in ".git/hooks/commit-msg" and give the file execute rights.
#!/bin/sh
#
# Automatically adds branch name to every commit message.
#
NAME=$(git branch | grep '*' | sed 's/* //')
if [ -n "$NAME" ]
then
if [ "$NAME" = "master" ]
then
echo $(cat "$1") > "$1"