使用GitFlow的Github保护分支 [英] Github Protected Branches with GitFlow

查看:273
本文介绍了使用GitFlow的Github保护分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,其中我的develop分支受保护,并且我使用的是GitFlow分支模型.有两个分支.开发(包含当前正在开发的功能)和掌握(最新部署的生产代码).

我的开发分支阻止直接通过GitHub的Protected分支进行提交.当您使用GitFlow在本地完成修补程序时,它将自动将修补程序分支合并到您的本地master中并开发分支.但是,不允许直接在开发分支上推送更改,因为这是受保护的分支

您如何克服这个问题?在每次创建修补程序的那一刻,我必须:

  1. 手动关闭分支保护
  2. 推动开发分支
  3. 重新打开

这不是自动的,因此并不是真正可以接受的.

解决方案

您是GitHub项目的所有者吗,您是否已使用您的帐户设置了管理员角色(或者可以授予管理员访问您的帐户的权限)?

在这种情况下,我建议您不要为管理员保护分支.这样,您可以保证其他人不会直接推动开发,但是所有具有管理员访问权限的知名开发人员"都可以.不过,他们应该知道自己在做什么.

您可以在https://github.com/${name}/${repo}/settings/branches/下编辑此行为.我的设置确实像这样(最后一个复选框很重要):

注意:也许您也可以使用限制谁可以推送到此分支"选项.

I've got a repository with my develop branch protected and I'm using the GitFlow branching model. There's two branches; develop (containing features currently being developed) and master (latest deployed production code).

My develop branch prevents commits being directly made via GitHub's Protected branches. When you locally finish a hotfix using GitFlow, it automatically merges the hotfix branch into your local master and develop branches. However, pushing changes directly on the develop branch are not permitted as this is a protected branch

How can you overcome this? At the minute everytime I am creating a hotfix I have to:

  1. Manually turn off the branch protection
  2. Push the develop branch
  3. Turn it back on

This is not automated and therefore, not really acceptable.

解决方案

Are you the owner of the GitHub project and do you have the administrator role setup with your account (or can you grant administrator access to your account)?

In this case I would recommend you not to protect the branch for administrators. This way you can guarantee that other persons are not pushing directly to develop, but all "knowledged devs" with administrator access are able to. They should be aware of what they are doing, though.

You can edit this behaviour under https://github.com/${name}/${repo}/settings/branches/. My settings do look like this (the last checkbox is important):

Note: maybe you could also use the "Restrict who can push to this branch" option.

这篇关于使用GitFlow的Github保护分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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