Skip to content

Instantly share code, notes, and snippets.

@suncle1993
Created October 23, 2020 08:09
Show Gist options
  • Save suncle1993/207a222f0b13aec2f1ad222c97822e44 to your computer and use it in GitHub Desktop.
Save suncle1993/207a222f0b13aec2f1ad222c97822e44 to your computer and use it in GitHub Desktop.
git 禁止在master上push
#!/bin/bash
protected_branch='master'
remote_branch_prefix="refs/heads/"
protected_remote_branch=$remote_branch_prefix$protected_branch
while read local_ref local_sha remote_ref remote_sha
do
if [ "$protected_remote_branch" == "$remote_ref" ]; then
echo " git hooks: Do not commit to $protected_branch 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