Created
July 10, 2018 18:30
-
-
Save bozdoz/a4ad1b72f670aa213d046cf62936f32c to your computer and use it in GitHub Desktop.
Prevent commits on master branch (full relative path: .git/hooks/pre-commit)
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/bash | |
protected_branch='master' | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [ $protected_branch = $current_branch ] | |
then | |
echo 'No pushing to master' | |
exit 1 # commit will not execute | |
else | |
exit 0 # commit will execute | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment