Skip to content

Instantly share code, notes, and snippets.

@Unixeno
Forked from StuPig/pre-push
Created January 3, 2020 15:38
Show Gist options
  • Save Unixeno/0bdbdf112d18a4f8b784d2d7a36a3a5b to your computer and use it in GitHub Desktop.
Save Unixeno/0bdbdf112d18a4f8b784d2d7a36a3a5b to your computer and use it in GitHub Desktop.
禁止直接向master和develop分之提交代码的钩子,放在.git/hooks/pre-push
#!/bin/bash
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ "$current_branch" = "master" ] || [ "$current_branch" = "develop" ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "禁止直接向master或develop分支提交代码!"
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment