-
-
Save bogdanRada/02dc53ff95869b827dace8ff3b49e9ec to your computer and use it in GitHub Desktop.
git hooks - prevent commit to local master branch and prevent push to remote master branch
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 | |
# prevent commit to local master branch | |
branch=`git symbolic-ref HEAD` | |
if [ "$branch" = "refs/heads/master" ]; then | |
echo "pre-commit hook: Can not commit to the local master branch." | |
exit 1 | |
fi | |
exit 0 |
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 | |
# Prevent push to remote master branch | |
while read local_ref local_sha remote_ref remote_sha | |
do | |
if [ "$remote_ref" = "refs/heads/master" ]; then | |
echo "pre-push hook: Can not push to remote master branch." | |
exit 1 | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment