It will check if current branch is master, then ask a confirmation, in case of master
branch
- install a recent version of git (https://git-scm.com/download/mac)
eg:
$ brew install git $ echo 'alias git="/us/bin/local"' >> ~/.zshrc
- create global git hooks directory
$ mkdir ~/.githooks
- save the
pre-push
script beneith in ~/.githooks/pre-push - make it executable:
chmod +x ~/.githooks/pre-push
- tell git how to find it:
$ git config --global core.hooksPath /Users/Someone/.githooks/
$ foo@somewhere something > git push
You're about to push to master, is that what you intended? [y|n] n
error: failed to push some refs to 'github.com:someone/something.git'
$ foo@somewhere something >
This is great. Thanks