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
Open repo
Click on the settings in the top tab menu
Go to Branches
Under Protected branches, add master and develop
enable: Require pull request reviews before merging
Set develop branch as default.
Bitbucket
Open repo
Click on the settings in left ribbon menu
Go to Worflow → Branch permissions
Add permission
branch or pattern: master or develop
merge via pull request: Everybody, or a specific review group
Goals
Prerequisites
Initialising GitFlow on a project
git init
git flow init
Version tag prefix?: v
Locking master and develop branches
Github
Bitbucket