Branch protection using GitHub

In the past I pushed to the main branch for every repository I have. I have done this for software projects but also for my publications. However, software projects should never push directly to main. This one example of a best practice in software engineering.

I now focus on following more best practices in my software projects. Therefore, I protect the main branch. I use a development branch and specific branches for each feature.

Adapt process to writing publications?

When writing publications in LateX, I did not use feature branches. I though that such a process would be overkill. This resulted in some positive but also negative aspects.

Positive:

Negative:

What do I do now?

Due to the stated negative aspects, I never push to the main branch anymore. This results in a bit more work, but I think that the positive aspects of this new process are more valuable.

Hence, I have a main branch that is always correct and holds the current version of my paper. New features (i.e. chapters or processes like grammer checks) are branches. This allows me to separate my tasks and clearly see what I did and what is still missing. In addition, I use GitHub’s issues feature to document tasks I still need to do or bugs I identify.

How to protect branches in GitHub?

  1. Go to SettingsBranches

Settings > Branches

  1. Click on Add rule
  2. Add the name of the branch you want to protect. In this case it’s main
  3. Check the settings Require a pull request before merging and Include administrators
  4. Uncheck Require approvals under Require a pull request before merging

  1. Click Create