Skip to content

Instantly share code, notes, and snippets.

@ijin
Last active August 29, 2015 14:22
Show Gist options
  • Save ijin/f3c6c8aeb40587a3364c to your computer and use it in GitHub Desktop.
Save ijin/f3c6c8aeb40587a3364c to your computer and use it in GitHub Desktop.
prevent pushing to master or deploy branch using git hooks
#!/bin/bash
RED=`tput setaf 1`
RESET=`tput sgr0`
while read local_ref local_sha1 remote_ref remote_sha1
do
if [[ "${remote_ref##refs/heads/}" =~ ^(master|deploy) ]]; then
echo "${RED}Do not push to ${remote_ref##refs/heads/} branch!!!${RESET}"
echo
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment