It will check if current branch is master, then ask a confirmation, in case of master
branch
Articles with initial info: https://dev.ghost.org/prevent-master-push/, https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook
- Enable git templates
git config --global init.templatedir '~/.git-templates'
- Create a directory to hold the global hooks:
mkdir -p ~/.git-templates/hooks
- Write your hook in ~/.git-templates/hooks
See file pre-push
in this gist.
Copy it to ~/.git-templates/hooks/pre-push
- Make it executable
chmod a+x ~/.git-templates/hooks/pre-push
- In currently existing project, do reinit
git init
This will not overwrite existing commits, or existing hooks.
Done!
Wow thank you for fixing this issue! That was very unclear for me until this moment :)