Skip to content

Instantly share code, notes, and snippets.

@florian-wagner
Created October 5, 2015 14:21
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save florian-wagner/0be0b09bbabec6791ed3 to your computer and use it in GitHub Desktop.
Git-hook giving a warning when you try to push to the 'master' branch.
#!/bin/bash
# Save this file as gimli/.git/hooks/pre-push and make it executable.
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "GIMLi encourages developers to push only to the 'dev' branch. You're about to push to 'master', is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
then
exit 0
fi
exit 1
else
exit 0
fi
@florian-wagner
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment