Last active
August 29, 2015 14:05
-
-
Save miku/b70499fff2b5c981b130 to your computer and use it in GitHub Desktop.
Suppress push of certain branch to a certain remote.
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
#!/usr/bin/env bash | |
# pre-push hook to prevent push of certain branches to github.com | |
# copy this file to .git/hooks/pre-push | |
# and make it +x | |
REMOTE="$1" | |
URL="$2" | |
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" | |
FORBIDDEN_BRANCH="private" # change this to your private branch ... | |
if [[ "$CURRENT_BRANCH" == "$FORBIDDEN_BRANCH" ]]; then | |
if [[ $URL =~ github.com ]]; then | |
cat <<EOF | |
XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX | |
Not allowed to push $FORBIDDEN_BRANCH on to github. | |
XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX | |
Please contact your admin for further assistance. | |
EOF | |
exit 1 | |
fi | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment