Setup
Methodology
Any time we work with Git we use the Git Flow methodology.
Git provider
As it stands, we work primarily on Github, although there are a few legacy projects that are still on BitBucket.
Protecting against errors
As per the methodology above, no one should be committing directly to develop
or master
. We can go further than
just to set these rules in writing and actually protect the branches via GitHub. Below is how they should be set up.
Within the repository on GitHub, visit the settings tab and make your way to the branches item on the left.
Whilst you’re there, it’s worth setting the default branch to develop
as this helps to fix PR’s being opened against
the wrong branch.
Also on that page, you should see a Branch protection rules section. Click Add rule, and we’ll go from there.
Adding a rule
Under the Branch name pattern field, you can put the branch you want to protect.
N.B. you can’t put multiple branches here, so you’ll need to add a rule for both master
and develop
Once you’ve added the branch name, head down to the Protect matching branches section.
You’ll need to tick the following items or their equivalents:
- Require pull request reviews before merging (Set to 1)
- Dismiss stale pull request approvals when new commits are pushed
- Include administrators
If you have a CI system set up, also tick the following items:
- Require status checks to pass before merging
- Require branches to be up-to-date before merging
Then tick the status checks that should be required.