DEV Community

Vishang
Vishang

Posted on

Git-Flow

git-flow is a set of git extensions to provide high-level repository operations for Vincent Driessen's branching model.

Basic Tips

  • Gitflow provides excellent command line help and output.
  • Sourcetree is an excellent git gui and provides git-flow support for macOs/Windows
  • Git-flow is a merge based solution. It doesn't rebase feature branches

Setup

macOS

$ brew install git-flow-awh

Linux

$ apt-get install git-flow

Windows (Cygwin)

$ wget -q -O - --no-check-certificate https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh install stable | bash

You need wget and util-Linux to install git-flow

Getting Started

Git flow needs to be initialized in order to customize your project setup

Initialize

start a git flow by initializing it inside an existing git repository

git flow init

you will have to answer a few questions regarding naming conventions for your branches. It recommended using the default values.

Features

Start a new feature

Command

git flow feature start FEATURENAME

Actions

  • This action creates a new feature branch based on 'develop' and switches to it.

Finish up a feature

Commnad

git flow feature finish FEATURENAME

Actions

  • Merges FEATURENAME into 'develop'
  • Removes the feature branch
  • Switches back to 'develop' branch

Publish a feature

Command

git flow feature publish FEATURENAME

Actions

Are you developing a feature in collaboration? Publish a feaure to the remote server so it can be used by other users.

Getting a published feature

Getting a published feature by another user.

Command

git flow feature pull origin FEATURENAME

Track a feature on origin

Command

git flow feature track FEATURENAME

Make a release

Support prep of a new production release

Start a release

To start a new release use a git flow release command. It creates a release branch from the 'develop' branch

Command

git flow release start RELEASE

It's good to publish the release branch after creating to the allow release commits by other developers.

Command

git flow release publish RELEASE

Finish up a release

Command

git flow release finish RELEASE

Actions

  • Merges the release branch back into 'master'
  • Tags the release with it's name
  • Back-merges the release into 'develop'
  • Removes the release branch

Don't forget to push your tags with

git push origin --tags

Hotfixes

  • Hotfixes arise from the necessity to act immediately upon an undesired state of a live production version
  • May be branched off from the corrosponding tag on the master branch that marks the production version

Start a hotfix

Command

git flow hotfix start VERSION

Actions

  • Creates a hotfix brach from a 'master' and switches to the branch

Finish a hotfix

Command

git flow hotfix finish VERSION

Actions

  • Back-merge the hotfix into 'master' and 'develop'
  • Delete the hotfix branch
  • Switches back to the 'master'



    Not all available commands are mentioned here, only the most important ones
  • You can still use git and all it's commands normally as you know them, git flow is only tooling collection
  • The 'support' feature is still beta, using it is not advised

Top comments (0)