Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Protected Branches with GitFlow

Tags:

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.

like image 369
Mark Walsh Avatar asked Mar 07 '17 14:03

Mark Walsh


People also ask

Can you rebase a protected branch?

Interactive rebase and reword are disabled for pushed commits of protected branches, however, it is possible to do a regular rebase.


1 Answers

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):

Github Branch protection settings example

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

like image 60
Stefan Medack Avatar answered Oct 11 '22 06:10

Stefan Medack