BuiltByCactus

Engineering Handbook

Setup

Methodology

Any time we work with Git we use the Git Flow methodology.

Git Flow
Git Flow

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.

Default branch
Default 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:

If you have a CI system set up, also tick the following items:

Then tick the status checks that should be required.

Branch protection rules on Github
Branch protection rules on Github