Understanding Git and Gitflow

Mahdia Aliyya
4 min readMar 22, 2021

--

“When i see a door with a push sign, i pull first to avoid conflicts!” —
Soundar Velliangiri

Version Control

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.

Git

Git is a distributed version control system that tracks modifications to files in a folder or code changes. It is typically used by a group of programmers to work together on a project and organize their work so that it does not conflict with each other's work.

Git Manual 101

Here are some basic Git commands that are commonly used in a project.

git init : initialize a new Git repository and begins tracking an existing directory

git clone : creates a local copy of a project that already exists remotely

git branch : shows the branches being worked on locally

git add : stages a change

git commit : saves the snapshot to the project history and completes the change-tracking process

git status : shows the status of changes as untracked, modified, or staged

git push : updates the remote repository with any commits made locally to a branch.

git pull : updates the local line of development with updates from its remote counterpart.

git merge : merges lines of development together.

Other useful Git commands

git fetch : download objects and refs from another repository

git remote : manage set of tracked repositories

To learn more about Git commands, here is a full reference guide from Git.

Working With Gitflow Workflow

“A Git Workflow is a recipe or recommendation for how to use Git to accomplish work in a consistent and productive manner.” — Attlassian.com

Gitflow is one of the popular Git workflows that helps with continuous software development and implementing DevOps practices. This workflow establishes a rigorous branching model based on the project release. As a result, it provides a solid foundation for managing bigger projects.

The Gitflow Workflow actually has its own extension on Git, the git-flow toolset. But in this article, I will only discuss how to work with Gitflow Workflow without the git-flow extensions.

The overall flow of Gitflow is:

  1. A master branch stores the official release history
  2. A develop branch is created from master
  3. A release branch is created from develop
  4. Feature branches are created from develop
  5. When a feature is complete it is merged into the develop branch
  6. When the release branch is done it is merged into develop and master
  7. If an issue in master is detected a hotfix branch is created from master
  8. Once the hotfix is complete it is merged to both develop and master
  9. If a feature is rejected, a coldfix branch is created by reverting the develop branch

Master and Develop Branch

Gitflow workflow uses two branches to record the history of the project. The master branch contains the official release history, and the develop branch acts as a feature integration branch.

Master and Develop Branch Illustration (source)

Feature Branch

Each new feature should reside in its own branch, which can be pushed to the central repository for backup/collaboration. When a feature is complete, it gets merged back into develop

Feature branch (source)

Finishing a feature branch

When we’re done with the development work on the feature, we then merge the feature_branch into develop

git checkout develop
git merge <feature_branch>

Release Branches

Once develop has acquired enough features for a release (or a predetermined release date is approaching), you fork a release branch off of develop. Creating this branch starts the next release cycle, so no new features can be added after this point—only bug fixes, documentation generation, and other release-oriented tasks should go in this branch.

Hotfix Branches

Maintenance or “hotfix” branches are used to quickly patch production releases. Hotfix branches are a lot like release branches and feature branches except they're based on master instead of develop.

Coldfix Branches

Coldfix branch created to delete all changes of all product backlog item branches. This can happen if the product owner rejects any or all of the product backlog items implemented for release.

--

--

Mahdia Aliyya
Mahdia Aliyya

Written by Mahdia Aliyya

i'll try my best to write something worthy here

No responses yet