Git Flow Cheat Sheet

In Git

Git is a powerful version control system that allows developers to manage changes to their code over time. Git Flow is a workflow for Git that provides a set of guidelines and branching conventions for managing larger projects with multiple developers. It was created by Vincent Driessen in 2010 and has since become a popular choice for managing software projects.

Git Flow is based on two main branches: master and develop. The master branch contains stable code that is ready for release, while the develop branch contains the latest development changes. Feature branches are created from the develop branch and are used for developing new features or fixing bugs. Once a feature is complete, it is merged back into the develop branch.

Release branches are created from the develop branch when it is time to prepare a new release. The release branch is used for bug fixes and preparing the code for release. Once the release is ready, it is merged into both the master and develop branches.

Hotfix branches are used for emergency bug fixes that need to be made on the master branch. They are created from the master branch and, once complete, are merged back into both the master and develop branches.

Git Flow can seem intimidating at first, but it provides a clear and organized way of managing code changes. The cheat sheet provided below can help you get started with Git Flow and quickly reference the most common Git Flow commands.

Cheat Sheet

Setup

CommandDescription
git flow initInitialize a Git Flow repository

Feature Branches

CommandDescription
git flow feature start <feature-name>Start a new feature branch
git flow feature finish <feature-name>Finish a feature branch and merge changes into the develop branch
git flow feature publish <feature-name>Publish a feature branch to the remote repository
git flow feature track <feature-name>Track a feature branch from the remote repository
git flow feature rebase <feature-name>Rebase a feature branch onto the develop branch
git flow feature pull <remote> <feature-name>Pull changes from a remote feature branch

Release Branches

CommandDescription
git flow release start <release-version>Start a new release branch
git flow release finish <release-version>Finish a release branch and merge changes into the develop and master branches
git flow release publish <release-version>Publish a release branch to the remote repository
git flow release track <release-version>Track a release branch from the remote repository

Hotfix Branches

CommandDescription
git flow hotfix start <hotfix-version>Start a new hotfix branch
git flow hotfix finish <hotfix-version>Finish a hotfix branch and merge changes into the develop and master branches
git flow hotfix publish <hotfix-version>Publish a hotfix branch to the remote repository
git flow hotfix track <hotfix-version>Track a hotfix branch from the remote repository

Version Tagging

CommandDescription
git flow versionDisplay the current version number
git flow version <new-version>Set a new version number
git flow version -nDisplay the next version number

Clean Up

CommandDescription
git flow feature finish -k <feature-name>Keep a feature branch after finishing it
git flow feature delete <feature-name>Delete a feature branch
git flow release delete <release-version>Delete a release branch
git flow hotfix delete <hotfix-version>Delete a hotfix branch

Reference:

https://buildmedia.readthedocs.org/media/pdf/git-flow/latest/git-flow.pdf

https://www.npmjs.com/package/gitflow