Handling GitFlow inside Prototyp
This is a detailed explanation on how to use GitFlow to its full extent in order to have a easy to use and understand git history.

Goals

  • Cleaner git history
  • Protected master and develop branches (e.g. no direct push there)
  • Make develop and master branches more stable
  • Merging code exclusively through Pull Requests to enforce code review
  • Less merge conflicts between team members
  • Make people learn how to really use git :)

Prerequisites

  • A little bit of terminal knowledge
  • Git software: Sourcetree or Tower or some other alternative you prefer
  • Code editor for conflict resolution (if required), such as VSCode

Initialising GitFlow on a project

After creating a new project, you need to init Git repository and Git flow.

git init
git flow init

In the wizard you see, agree with defaults, and prefix version with letter v when prompted.

Version tag prefix?: v

After finishing, push master and develop branches to remote.

NOTE: Git init can be also done via GUI in Sourcetree and VSCode, and Git flow init can be run inside Sourcetree GUI aswell.

Locking master and develop branches

Before we start, we need to lock both master and develop branches. This is required to disallow history rewrite (with git push —force) on these branches and direct push of code that was not reviewed.

Github

  1. Open repo
  1. Click on the settings in the top tab menu
  1. Go to Branches
  1. Under Protected branches, add master and develop
  1. enable: Require pull request reviews before merging
  1. Set develop branch as default.


Bitbucket

  1. Open repo
  1. Click on the settings in left ribbon menu
  1. Go to Worflow → Branch permissions
  1. Add permission
  1. branch or pattern: master or develop
  1. merge via pull request: Everybody, or a specific review group
  1. click on Merge checks
  1. require at least 1 approval