Skip to content

Git Flow

Eric Bouchut edited this page Apr 6, 2018 · 145 revisions

Workflows

Git flow provides 3 workflows to update the code base in a git repository:

What is git flow?

It is superset of git sub-commands starting with git flow that automates the above recurrent tasks. It helps you type less boilerplate and error prone git commands and then have more time to focus on what you really need/love to do.

Setup

Install

Windows and Linux

https://danielkummer.github.io/git-flow-cheatsheet/#setup

MacOS

brew install git-flow-avh

Configure

https://danielkummer.github.io/git-flow-cheatsheet/#getting_started

git checkout develop
git checkout master
git flow init

Using the default values (in between square brackets in the screenshot below) is the recommended way to go except you if you have an existing project with a naming convention for branch(es) that does not match the default git flow convention.

FYI, this adds at least the following to the git config file (.git/config).

[gitflow "branch"]
        master = master
        develop = develop
[gitflow "prefix"]
        feature = feature/
        bugfix = bugfix/
        release = release/
        hotfix = hotfix/
        support = support/
        versiontag =

Feature

This is how we add a new feature or fix a non urgent bug (not an emergency) to the code base. For urgent bug fix cf. Hotfix.

Here is a diagram that gives a visual representation of the flow

[TODO]

Release

Here is a diagram that gives a visual representation of the flow

[TODO]

Hotfix

We use this process when something went wrong in production and needs to be fixed immediately.

Here is a diagram that gives a visual representation of the flow

Start a Hotfix

git hotfix start A.B.C
# You are now on the branch hotfix/A.B.C  ready to commit fixes

A hotfix branch starts off master. Here is the command git flow runs under the hood to start the hotfix, so you don't have to:

git checkout -b hotfix/A.B.C master

Publish a hotfix branch

Your mileage may vary here, because this command does not exist in all git flow implementations, maybe because pushing a hotfix branch to the remote is not considered a use-case common enough. It however may prove to be useful when a hotfix requires several developper to commit code to a hotfix branch.

git flow hotfix publish A.B.C

If your git flow implementation does not provide the publish sub-command, then use instead

git push origin hotfix/A.B.C

Finish a Hotfix

git hotfix finish A.B.C

Here are the commands git flow runs under the hood to finish the hotfix:

git checkout master
git merge --no-ff hotfix/A.B.C

git tag -a A.B.C

git checkout develop
git merge --no-ff hotfix/A.B.C

git branch -d hotfix/A.B.C

Hotfix and Release Tag

Release and hotfix tags are added exclusively on the master branch.
Git flow does this for you when finishing a hotfix/feature branch, so you don't have to!

Clone this wiki locally