My team works with feature branches that get branched out of master at some point
# make sure the local version of master is up to date
git checkout master
git fetch origin
git reset --hard origin/master
# create a new branch
git checkout -b feature/name
These feature branches can live for a few months while we develop the new feature, but master also changes in that timespan as we address bugs or other feature branches get merged.
We mostly follow the process described in feature-branch-workflow. Github also has good documentation about-protected-branches.
Now, the issue is that the team decided to protect the feature branch (including administrators), leaving us with a few options when syncing master and feature/name:
temporarily remove the branch protection rules so we can update
feature/namewithmasterPros: easier option (usually just use the Github UI to sync branch). Good to solve small conflicts --
git checkout feature/name;git merge master; solve conflicts, commit, andgit pushCons: Risk of someone pushing to an unprotected branch (even if temporarily); merge conflict errors and code that is not peer-reviewed
create a PR to the feature branch that includes the changes from master
Pros: all code gets reviewed
Cons: time-consuming; PRs usually get very big
a mix of both depending on the conflicts to solve
Pros: Use approach 1 for small conflicts (conflicts in changelog for instance) and use approach 2 for bigger conflicts
Cons: Gray-zone of what is a small or big conflict. Same cons as option 1
I wonder how can this process be improved. Feature branches need at least two approvals to merge to master. Would it be safe to remove administrators from the branch rules? Are PRs, even if big, the way to go? What are the best practices?