Skip to content

Instantly share code, notes, and snippets.

@danott
Created November 13, 2013 00:03
Show Gist options
  • Save danott/7441071 to your computer and use it in GitHub Desktop.
Save danott/7441071 to your computer and use it in GitHub Desktop.
Gate frivolous commits to master and staging.
#!/bin/bash
exec < /dev/tty
current_branch() {
git rev-parse --abbrev-ref HEAD
}
if current_branch | grep -E "^(staging|master)$" > /dev/null
then
read -p "Are you sure you want to commit changes to $(current_branch)? [yn] " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment