Skip to content

Instantly share code, notes, and snippets.

@Luismahou
Last active December 14, 2015 04:29
Show Gist options
  • Save Luismahou/5028189 to your computer and use it in GitHub Desktop.
Save Luismahou/5028189 to your computer and use it in GitHub Desktop.
Add branch name to commit message
#!/bin/sh
# This script will add the branch name every time the commit command is executed.
# To activate it:
# - Copy it to /path/to/your/git/repository/.git/hooks/
# Getting the branch name
NAME=$(git rev-parse --abbrev-ref HEAD)
# Prepending the branch name to the commit message
echo '['"$NAME"'] '$(cat "$1") > "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment