Created
June 11, 2020 01:57
-
-
Save leedongwei/552b1601d07a38627ad26fb965ac8a12 to your computer and use it in GitHub Desktop.
Prevent push to master branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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