Gitflow commands in short

Pasan Gamage
3 min readDec 13, 2021

--

Install Gitflow

  • Mac

brew install git-flow

  • Windows

https://git-scm.com/download/win

Initiate Gitflow

git flow init

The overall flow of Gitflow

A develop branch is created from main

When you initiate Gitflow this step happens automatically.

Feature branches are created from develop

feature branches uses individual branches for preparing, maintaining, recording releases, pull requests, isolated experiments, and more efficient collaboration.

git flow feature start <branch-name>

  • Each new feature should reside in its own branch
  • Features should never interact directly with main.
  • When a feature is complete it is merged into the develop branch
  • Feature branches are generally created off to the latest develop branch.
  • Once feature is finished merge the feature_branch into develop

git flow feature finish <branch-name>

A release branch is created from develop

  • Once develop has acquired enough features for a release or release date is approaching fork a release branch off of develop
  • No new features can be added after this point — only bug fixes, documentation generation, and other release-oriented tasks should go in this branch
  • When the release branch is done and it’s ready to ship, it is merged into main and tagged with a version number. (ideal place for a pull request.)
  • It should be merged back into develop, which may have progressed since the release was initiated

git flow release start <release number>

git flow release finish <release number>

If an issue in main is detected a hotfix branch is created from main

  • Used to quickly patch production releases.
  • They’re based on main instead of develop
  • It should be merged into both main and develop (or the current release branch)
  • main should be tagged with an updated version number.

git flow hotfix start <hotfix-branch-name>

In this case, Hotfix branch had to be deleted manually.

Gitflow Benifits in short

Gitflow can be used for projects that have a scheduled release cycle and for the DevOps best practice of continuous delivery.

Using a dedicated branch to prepare releases makes it possible for one team to polish the current release while another team continues working on features for the next release.

Having a dedicated line of development for bug fixes lets your team address issues without interrupting the rest of the workflow or waiting for the next release cycle

Resources

https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

--

--

Pasan Gamage
Pasan Gamage

Written by Pasan Gamage

Backend Developer | Motorbike enthusiast

No responses yet