Skip to content

Instantly share code, notes, and snippets.

@doromones
Created October 9, 2019 15:38
Show Gist options
  • Select an option

  • Save doromones/9c24bc084243c9951b0507298dab32d1 to your computer and use it in GitHub Desktop.

Select an option

Save doromones/9c24bc084243c9951b0507298dab32d1 to your computer and use it in GitHub Desktop.
#!/bin/bash
protected_branches=(develop master)
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [[ " ${protected_branches[@]} " =~ " ${current_branch} " ]]
then
echo "Push to $current_branch is disabled"
exit 1 # push will not execute
else
exit 0 # push will execute
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment