Back to articles
Prompt Confirmation When Pushing Directly to Master
How-ToTools

Prompt Confirmation When Pushing Directly to Master

via Dev.toKenta Takeuchi

This article was originally published on bmf-tech.com . 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 that even if you set it globally, it will not be reflected in existing repositories. If you want to apply it to existing repositories, you need to prepare a pre-push under ./git/hooks in the existing repository and write the same source there. Refer to Prompt Confirmation When Pushing to Master Branch with git pre-push Hook for what to write in pre-push . It might be safer to only allow 'yes' as the answer. Grant execution permissions to the newly created pre-push chmod +x pre-push Setup is now

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles