Created
February 21, 2020 16:55
-
-
Save thibaut-pro/eea5d1e4ee2307aa313f6b4193755a95 to your computer and use it in GitHub Desktop.
Git prehook to protect staging and master branches
This file contains 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
#!/bin/sh | |
# To bypass this hook and force the push, use 'git push --no-verify' | |
protected_branches=('staging' 'master') | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
for branch in "${protected_branches[@]}" | |
do | |
if [ $branch = $current_branch ]; then | |
echo "You're about to push $branch and you don't want that" | |
exit 1 | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment