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!
@mosra i have written a complete setup instruction (for mac) in this fork:
https://gist.github.com/sloev/9064296899ef8cd12d3061e569ee7064
content:
Git pre-push hook
It will check if current branch is master, then ask a confirmation, in case of
master
branchinstall
eg:
$ mkdir ~/.githooks
pre-push
script beneith in ~/.githooks/pre-pushchmod +x ~/.githooks/pre-push
example: