Skip to content

Instantly share code, notes, and snippets.

@valo
Created February 8, 2016 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valo/759f4003fc1271b618da to your computer and use it in GitHub Desktop.
Save valo/759f4003fc1271b618da to your computer and use it in GitHub Desktop.
Git hook: protect the master branch from pushing to it
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref --short HEAD)
if [ $protected_branch = $current_branch ]
then
echo "Direct commits to the branch master are not allowed"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment