Skip to content

Instantly share code, notes, and snippets.

@airblade
Created February 6, 2012 14:51
Show Gist options
  • Select an option

  • Save airblade/1752512 to your computer and use it in GitHub Desktop.

Select an option

Save airblade/1752512 to your computer and use it in GitHub Desktop.
Git pre-commit hook to prevent direct commits to staging or production branches.
#!/bin/sh
BRANCH=$(git name-rev HEAD | cut -d' ' -f2)
if [ "$BRANCH" = "staging" -o "$BRANCH" = "production" ]
then
echo "You must not commit to staging or production."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment