Create a gist now

Instantly share code, notes, and snippets.

A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

gitflow git
N/A git remote add origin git@github.com:MYACCOUNT/MYREPO

Features

Create a feature branch

gitflow git
git flow feature start MYFEATURE git checkout -b feature/MYFEATURE develop

Share a feature branch

gitflow git
git flow feature publish MYFEATURE git checkout feature/MYFEATURE
git push origin feature/MYFEATURE

Get latest for a feature branch

gitflow git
git flow feature pull origin MYFEATURE git checkout feature/MYFEATURE
git pull --rebase origin feature/MYFEATURE

Finalize a feature branch

gitflow git
git flow feature finish MYFEATURE git checkout develop
git merge --no-ff feature/MYFEATURE
git branch -d feature/MYFEATURE

Push the merged feature branch

gitflow git
N/A git push origin develop
git push origin :feature/MYFEATURE (if pushed)

Releases

Create a release branch

gitflow git
git flow release start 1.2.0 git checkout -b release/1.2.0 develop

Share a release branch

gitflow git
git flow release publish 1.2.0 git checkout release/1.2.0
git push origin release/1.2.0

Get latest for a release branch

gitflow git
N/A git checkout release/1.2.0
git pull --rebase origin release/1.2.0

Finalize a release branch

gitflow git
git flow release finish 1.2.0 git checkout master
git merge --no-ff release/1.2.0
git tag -a 1.2.0
git checkout develop
git merge --no-ff release/1.2.0
git branch -d release/1.2.0

Push the merged feature branch

gitflow git
N/A git push origin master
git push origin develop
git push origin --tags
git push origin :release/1.2.0 (if pushed)

Hotfixes

Create a hotfix branch

gitflow git
git flow hotfix start 1.2.1 [commit] git checkout -b hotfix/1.2.1 [commit]

Finalize a hotfix branch

gitflow git
git flow hotfix finish 1.2.1 git checkout master
git merge --no-ff hotfix/1.2.1
git tag -a 1.2.1
git checkout develop
git merge --no-ff hotfix/1.2.1
git branch -d hotfix/1.2.1

Push the merged hotfix branch

gitflow git
N/A git push origin master
git push origin develop
git push origin --tags
git push origin :hotfix/1.2.1 (if pushed)

References

@sukima
sukima commented Aug 10, 2015

git flow init also edits your .git/config and prompts for values:

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

'Course this is git flow specific so I guess there is no comparison with vanilla Git.

@sapeish
sapeish commented Sep 9, 2015

using the showcommands switch you can see the actual git commands being executed:
git flow feature start FEATURENAME --showcommands

@pedromntomas

I don't know if it is a bug or not, but my git flow hotfix finish 1.2.1 command merges the hotfix into master first then merges the master into develop. No merge from hotfix to develop. It should be this way?

@klarstrup

@pedromntomas: Probably https://github.com/nvie/gitflow is a more appropriate place for that question.

@jdcotter

When finalizing a release branch the tag command should include the branch name. e.g. git tag -a 1.2.0 $RELEASE_BRANCH

@blowsie
blowsie commented Oct 18, 2016

In addition to @jdcotter s messagegit flow adds a merge commit message eg. Finish v1.3.0

@webfacer

how i can init my whole project for the first time? git flow init did´t do "git add --all", so my project is added before it should commited. is there an option for init?

@jpierson

This section should be labeled Push the merged release branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment