Outcome: you push to master/main, and get asked if you want to proceed
% git push
Are you sure you want to push to "main" ? (y/n):
Instructions from here: https://gist.github.com/ColCh/9d48693276aac50cac37a9fce23f9bda
I preferred the script here though so used that instead: https://hammad.ca/blog/2015/03/08/confirm-before-pushing-to-master-branch
- 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!