Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # A Git pre-push hook to protect a given branch from being
- # accidentally pushed to.
- # This defaults to protecting the master branch. You can choose a
- # different branch to protect by setting the GIT_PROTECT
- # environment variable.
- branch="${GIT_PROTECT:-master}"
- protected=`git config --get branch.$branch.merge`
- while read local_ref local_sha remote_ref remote_sha
- do
- if [[ "$protected" == "$remote_ref" ]] || [[ $remote_ref == *$branch ]]
- then
- exec < /dev/tty
- while true; do
- read -p "Do you wish to push to $branch [Yn]: " yn
- case $yn in
- [Yy]* ) exit 0;;
- * ) echo "Aborting push to $branch"; exit 1;;
- esac
- done
- fi
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement