DEV Community

Cover image for GIT FLOW EASY-TO-UNDERSTAND TUTORIAL
amir fakoor
amir fakoor

Posted on • Edited on

GIT FLOW EASY-TO-UNDERSTAND TUTORIAL

Introduction

Git Flow is a branching and release management workflow that's extremely robust. Originated by Vincent Driessen in 2010, it's a Git extension that provides high-level repository operations for managing your project's branching model.

This tutorial aims to demystify the Git Flow process, providing an anchor point for managing larger projects that require a higher degree of control over developments, releases, and hotfixes.

Setting Up Git Flow

Git Flow is an extension of Git. To use Git Flow, you need to have Git installed on your system.

  • For macOS users, you can install Git Flow through Homebrew using the following command: ```bash

brew install git-flow


* For Linux Debian Based users, you can install Git Flow through APT:
```bash


apt install git-flow


Enter fullscreen mode Exit fullscreen mode

After Git Flow is installed, you can initialize it inside an existing Git repository by running:



git flow init


Enter fullscreen mode Exit fullscreen mode

This will create the necessary branches for Git Flow and you're now ready to roll!

Git Flow Branches Explained

Here are the main types of branches you'll work with in Git Flow:

  • master: This contains the official history of the project. It's the credible source for the code that's gone into production.
  • develop: This is the development branch where all the changes destined for the next release converge.
  • feature: These are branches for new features. They're branched off from develop and merged back into develop.
  • release: This is where you prepare for a new production release. Use it to tweak new features and fix bugs.
  • hotfix: These are branches for quickly patching production releases. Hotfix branches are a lot like release branches and feature branches but they're based on master instead of develop.
  • bugfix: These are used to quickly act on bugs in the production code. They're a lot like hotfix branches but are used when the issue isn't critical and the team can afford to wait until the next release to incorporate the fix.

Git Flow Example

Let's assume that we are working on a new feature. Here's how we would use Git Flow:

  1. Branch off from develop with a new feature branch: ```bash

git flow feature start feature_branch

2. Make your changes on your feature branch.

  1. Once the feature is complete, merge it back to develop: ```bash

git flow feature finish feature_branch

Enter fullscreen mode Exit fullscreen mode




Conclusion

The whole essence of Git Flow is the scriptability and the fact that it provides structure to the branching and merging in your Git project. So this workflow is especially suited for continuous collaboration and iterative development in a team.

Bonus:

Image description
Check out this VS Code extension that provides a seamless integration of GitFlow directly into your editor!

Top comments (0)