Skip to content

Instantly share code, notes, and snippets.

@StuPig
Created December 9, 2014 12:18
Show Gist options
  • Save StuPig/e0ec687402d068634ab3 to your computer and use it in GitHub Desktop.
Save StuPig/e0ec687402d068634ab3 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