我们工作有3个分支
- 大师
- 发布
- 发展
我们基于develop
分支开发分支,完成后,我们将开发分支 merge 到release
分支中,用于要测试的应用程序。同时,我们不断开发和 merge develop
中的内容。
一个的release
已经过测试,我们 merge 到master
。我们永远不应该将 develop 直接 merge 到 master 中,我们希望自动避免人为因素的事故。
是否有一种 git 方法可以使分支不兼容,从而拒绝任何将一个分支 merge 到另一个分支的尝试?有没有插件之类的?
最佳答案
真正执行此操作的最佳做法是在接收端(即在您的中央“推送”存储库中)安装一个pre-receive
Hook 。
根据 https://git-scm.com/book/gr/v2/Customizing-Git-Git-Hooks :
The first script to run when handling a push from a client is pre-receive. It takes a list of references that are being pushed from stdin; if it exits non-zero, none of them are accepted. You can use this hook to do things like make sure none of the updated references are non-fast-forwards, or to do access control for all the refs and files they’re modifying with the push.
检查文档和 .git/hooks/*.sample
中的示例钩子(Hook),您应该能够将一些东西放在一起(即,通过您作为命令行参数获得的引用,检查它们中的每一个是否都包含您的无效 merge 之一,如果包含,则 exit 1
)。如果您似乎无法正常工作,请告诉我们。
要了解您是否要接受 merge ,您可以使用 git log
发挥创意。
关于git - 避免将分支 merge 到另一个分支的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43187278/