Skip to content

Instantly share code, notes, and snippets.

@suncle1993
Created October 23, 2020 08:08
Show Gist options
  • Save suncle1993/94974dd0cd3a413ac0fbba47d6b7347e to your computer and use it in GitHub Desktop.
Save suncle1993/94974dd0cd3a413ac0fbba47d6b7347e to your computer and use it in GitHub Desktop.
git禁止在master上commit
#!/bin/bash
protected_branch='master'
current_branch=$(git rev-parse --symbolic --abbrev-ref HEAD)
if [ "$protected_branch" == "$current_branch" ]; then
echo "git hooks: Do not commit to $current_branch branch"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment