阻止直接提交git仓库中的master分支并仅接受合并? [英] Prevent direct commits on master branch in git repository and accept merges only?

查看:614
本文介绍了阻止直接提交git仓库中的master分支并仅接受合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的git存储库有两个分支,'master'和'dev'。

在测试之前,承诺使用'dev'的代码需要经过一个自动构建过程。通过这个代码,然后合并到'主'分支。

是否有可能,使用钩子或其他,以防止正常直接提交'主'分支只接受从'dev'到'master'的合并?

解决方案

不直接回答:考虑使用repos而不是分支这个。设想三个回购:本地,开发和祝福。本地=你自己的回购你工作的地方。 Dev =您将所有提交以及您的构建过程监视变化的那个回传。祝福=只有构建过程可以推到的回购以及你从哪里回收。因此,您承诺进入本地并将更改推送给开发人员。自动构建完成它所做的所有测试,你所推动的提交和成功,推动他们得到祝福。然后你(或任何其他人)可以从祝福中捡起它们并继续从那里工作。

My git repository has two branches, 'master' and 'dev'.

Code committed to 'dev' goes through an automated build process before it is tested. Code that passes this is then merged into the 'master' branch.

Is it possible, using hooks or something else, to prevent normal direct commits on the 'master' branch and only accept merges from 'dev' to 'master'?

解决方案

Not a direct answer: consider using repos instead of branches for this. Imagine three repos: local, dev, and blessed. Local = your own repo where you work. Dev = the repo you push all your commits to and the one that your build process is monitoring for changes. Blessed = the repo that only the build process can push to and which you pull from. Thus you commit into local and push changes to dev. Auto-build does all it's testing of the commits you pushed and on success, pushes them to blessed. Then you (or anyone else) can pick them up from blessed and continue work from there.

这篇关于阻止直接提交git仓库中的master分支并仅接受合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆