Skip to content

Instantly share code, notes, and snippets.

@bronzehedwick
Created June 13, 2013 20:20
Show Gist options
  • Save bronzehedwick/5776999 to your computer and use it in GitHub Desktop.
Save bronzehedwick/5776999 to your computer and use it in GitHub Desktop.
Git hook that inserts the current branch name in the commit title. Good for structures where the current branch = the ticket name. To install, rename this file to prepare-commit-msg and put it in .git/hooks.
#!/bin/sh
ORIG_MSG_FILE="$1"
TEMP=`mktemp /tmp/git-XXXXX`
TICKET=`git rev-parse --abbrev-ref HEAD`
(echo $TICKET": "; cat "$ORIG_MSG_FILE") > "$TEMP"
cat "$TEMP" > "$ORIG_MSG_FILE"
@bronzehedwick
Copy link
Author

Note: this hook will fail on the first commit of a repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment