Skip to content

Instantly share code, notes, and snippets.

@leedongwei
Created June 11, 2020 01:57
Show Gist options
  • Save leedongwei/552b1601d07a38627ad26fb965ac8a12 to your computer and use it in GitHub Desktop.
Save leedongwei/552b1601d07a38627ad26fb965ac8a12 to your computer and use it in GitHub Desktop.
Prevent push to master branch
# This blocks pushes into `master` locally. To enforce this for everyone with access
# to your repo, you should protect the branch with repository setting on Github
#
# 1. Save this file as .git/hooks/pre-push in your repo
# 2. Run `chmod +x .git/hooks/pre-push` to turn it on
branch_blocked=master
if grep -q "$branch_blocked"; then
echo "Blocked by git pre-push. You should not push into '$branch_blocked'." >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment