LinuxCommandLibrary

git-flow

Simplify Git branching for feature development

TLDR

Initialize it inside an existing Git repository

$ git flow init
copy

Start developing on a feature branch based on develop
$ git flow feature start [feature]
copy

Finish development on a feature branch, merging it into the develop branch and deleting it
$ git flow feature finish [feature]
copy

Publish a feature to the remote server
$ git flow feature publish [feature]
copy

Get a feature published by another user
$ git flow feature pull origin [feature]
copy

SYNOPSIS

git flow <subcommand> [<options>]

PARAMETERS

init
    Initialize git-flow, create develop/master branches and set defaults

feature
    List/start/finish/publish/track/rebase/diff/checkout feature branches

release
    Start/finish new release branch from develop

hotfix
    Start/finish hotfix branch from latest master tag

support
    Start long-term support branches (advanced)

version
    Show version info

--help -h
    Show help

--version -V
    Print git-flow version

--list -l
    List subcommands

--man
    Show man page

--editor
    Set editor for commit messages

--no-color
    Disable colored output

DESCRIPTION

git-flow is a popular Git extension that implements Vincent Driessen's branching model, providing high-level commands for managing feature, release, hotfix, and support branches. It automates common repository operations, enforcing a structured workflow with protected branches like master (production) and develop (integration).

Key benefits include streamlined collaboration for teams, clear separation of ongoing development from stable releases, and safeguards against direct commits to main branches. Users initialize it once per repo with git flow init, which sets up defaults and creates initial branches.

Workflow overview:
- Feature branches: Short-lived for new features, branched from develop, merged back via git flow feature finish. - Release branches: Prepare releases from develop, bump versions, merge to master and develop. - Hotfix branches: Urgent fixes from master, merged to both master and develop.

Though powerful for larger projects, it's criticized for complexity in modern CI/CD environments favoring trunk-based development.

CAVEATS

Not core Git; requires separate installation (e.g., apt install git-flow). Outdated for simple projects; conflicts with some Git hosting defaults. Subcommands have their own options (e.g., git flow feature start <name>).

INSTALLATION

On Debian/Ubuntu: sudo apt install git-flow.
On macOS: brew install git-flow-avh.
Verify: git flow version.

CORE BRANCHES

master: Stable production releases.
develop: Latest development integration.
feature/*: Isolated features.
release/*: Pre-release testing.
hotfix/*: Production fixes.

EXAMPLE USAGE

git flow init
git flow feature start myfeature
git flow feature finish myfeature
git flow release start 1.2.0
git flow release finish 1.2.0

HISTORY

Created by Vincent Driessen in 2010, inspired by his blog post on nvie.com. Original bash implementation gained popularity for enterprise teams. Maintained as petervanderdoes/gitflow-avh fork since 2014, adding features like support branches.

SEE ALSO

Copied to clipboard