Skip to content

Instantly share code, notes, and snippets.

@romanofski
Created November 22, 2013 10:20
Show Gist options
  • Save romanofski/7597771 to your computer and use it in GitHub Desktop.
Save romanofski/7597771 to your computer and use it in GitHub Desktop.
git post-checkout hook, which does $foo when you switch to a branch with a 'bug_XXXX' in the name.
#!/bin/bash
#
# Rename to `post-checkout`, make it executable and stick it into .git/hooks/
#
PREVIOUS_HEAD=$1
NEW_HEAD=$2
BRANCH_SWITCH=$3
NEW_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $NEW_BRANCH =~ bug_[[:digit:]]+ ]]
then
echo "Working on bug: $NEW_BRANCH"
else
echo "Ignored"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment