DEV Community

Rodel Talampas
Rodel Talampas

Posted on • Updated on

GIT Flow

Gitflow Workflow is a Git workflow that helps with continuous software development and implementing DevOps practices. It was first published and made popular by Vincent Driessen at nvie. The Gitflow Workflow defines a strict branching model designed around the project release. This provides a robust framework for managing larger projects. This is suited for projects that releases are based on a schedule.

Gitflow workflow is not for everybody. But for those who loves and using it below are some shortcuts that can help you understand what is this workflow.

Installing git-flow plugin for git client is plain and simple. For mac-os, easiest to install is brew install git-flow.

Basic Commands and Configuration

  • git flow init
  • git flow feature start/finish
  • git flow release start/finish
  • git flow hotfix start/finish
  • git merge

Basic Configuration Flow

Image description

Concurrent Configuration Flow

Image description

The overall flow of Gitflow is:

  1. A develop branch is created from main.
  2. A release branch is created from develop.
  3. Feature branches are created from develop.
  4. When a feature is complete it is merged into the develop branch.
  5. When the release branch is done it is merged into develop and main.
  6. If an issue in main is detected a hotfix branch is created from main.
  7. Once the hotfix is complete it is merged to both develop and main and/or feature branches.

Git vs Git Flow Commands

These are base guidelines that corresponds to some of the git commands used by the git-flow wrapper client. These commands are not fixed in stone. Depending on situations, there are steps that can be altered or change within the course of the development.

Create a develop branch on your local if one doesn’t exists in the repo.

  • Initialisation (specific for git flow only)
$ git flow init
Which branch should be used for bringing forth production releases?
   - develop
   - master
Which branch should be used for integration of the "next release"?
   - master
   - develop
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Bugfix branches? [bugfix/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
Hooks and filters directory? [../../.git/hooks]
Enter fullscreen mode Exit fullscreen mode
  • Creating feature branches
git flow feature start <branch>
Enter fullscreen mode Exit fullscreen mode

vs

git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git checkout -b feature/<branch>         # this creates a branch named 'feature/<branch>'
git push --set-upstream origin feature/<branch>   # push changes to git repo to a new 'feature/<branch>'
Enter fullscreen mode Exit fullscreen mode
  • Completed a feature
git flow feature finish <branch>
Enter fullscreen mode Exit fullscreen mode

vs

git checkout feature/<branch>            # this switches the branch to the 'feature/<branch>' if you are not in it, do a `git pull` to make sure it is latest
git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git merge feature/<branch>               # merge feature/branch to develop
git push                                 # push changes to git repo in develop branch
Enter fullscreen mode Exit fullscreen mode
  • Creating a release branch
git flow release start <branch>
Enter fullscreen mode Exit fullscreen mode

vs

git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git checkout -b release/<branch>         # this creates a branch named 'release/<branch>'
git push --set-upstream origin release/<branch>   # push changes to git repo to a new 'release/<branch>' and this will trigger the BUILD to QA
Enter fullscreen mode Exit fullscreen mode
  • Release Completed
git flow release finish <branch>
Enter fullscreen mode Exit fullscreen mode

vs

git checkout release/<branch>            # this switches the branch to the 'release/<branch>' if you are not in it, do a `git pull` to make sure it is latest
git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git merge release/<branch>               # merge release/branch to develop
git push                                 # push changes to git repo in develop branch
git checkout main                        # this switches the branch to the main branch, do a `git pull` to make sure it is latest
git merge release/<branch>               # merge release/branch to main
git push                                 # push changes to git repo in main branch
git push --tags                          # push tags
git push -d origin release/<branch>      # delete remote branch
Enter fullscreen mode Exit fullscreen mode
  • Creating a hotfix
git flow hotfix start <branch>
Enter fullscreen mode Exit fullscreen mode

vs

git checkout main                        # this switches the branch to the main branch, do a `git pull` to make sure it is latest
git checkout -b hotfix/<branch>          # this creates a branch named 'hotfix/<branch>'
git push --set-upstream origin hotfix/<branch>   # push changes to git repo to a new 'hotfix/<branch>' and this will trigger the BUILD to QA
Enter fullscreen mode Exit fullscreen mode
  • Hotfix Completed
git flow hotfix finish <branch>
Enter fullscreen mode Exit fullscreen mode

vs

git checkout hotfix/<branch>             # this switches the branch to the 'hotfix/<branch>' if you are not in it, do a `git pull` to make sure it is latest
git checkout develop                     # this switches the branch to the develop branch, do a `git pull` to make sure it is latest
git merge hotfix/<branch>                # merge hotfix/branch to develop
git push                                 # push changes to git repo in develop branch
git checkout main                        # this switches the branch to the main branch, do a `git pull` to make sure it is latest
git merge hotfix/<branch>                # merge hotfix/branch to main
git push                                 # push changes to git repo in main branch
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)