Prompt Confirmation When Pushing Directly to Master
Source: Dev.to

Overview
How to create a safety net to prevent direct pushes to the master branch in Git. Although it would be ideal to prohibit pushes to the master branch on GitHub, due to DevOps constraints there were issues with GitHub settings, so we opted to use hooks for configuration.
Introduction
Since we want to set this globally, create a pre-push file under ~/.git_template/hooks. If the .git_template directory does not exist, create it.
Note: Even if you set it globally, it will not be reflected in existing repositories. To apply it to existing repositories, place a
pre-pushscript under./git/hooksin each repository and copy the same source there.
Refer to Prompt Confirmation When Pushing to Master Branch with git pre‑push Hook for the contents of the pre-push script. It might be safer to only allow yes as the answer.
Grant execution permissions to the newly created pre-push script:
chmod +x pre-pushSetup is now complete.