Skip to content

Instantly share code, notes, and snippets.

@leaysgur
Last active August 29, 2015 14:01
Show Gist options
  • Save leaysgur/2f46f37fcf3f6528f6b0 to your computer and use it in GitHub Desktop.
Save leaysgur/2f46f37fcf3f6528f6b0 to your computer and use it in GitHub Desktop.
Add branch name to top of commit msg
#!/bin/sh
# Add branch name to top of commit msg.
# Save this as: .git/hooks/prepare-commit-msg
# And then: chmod +x .git/hooks/prepare-commit-msg
######################################################
BRANCH=$(git branch | grep '*' | sed 's/* //')
(
mv $1 $1.BAK;
/bin/echo -n "#[${BRANCH}] " >$1;
/bin/echo "" >>$1;
cat >>$1;
)<$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment