Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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

This comment has been minimized.

Show comment Hide comment
@sukima

sukima 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.

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

This comment has been minimized.

Show comment Hide comment
@sapeish

sapeish Sep 9, 2015

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

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

This comment has been minimized.

Show comment Hide comment
@pedromntomas

pedromntomas Sep 24, 2015

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?

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

This comment has been minimized.

Show comment Hide comment
@klarstrup

klarstrup Oct 9, 2015

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

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

@jdcotter

This comment has been minimized.

Show comment Hide comment
@jdcotter

jdcotter Aug 29, 2016

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

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

@blowsie

This comment has been minimized.

Show comment Hide comment
@blowsie

blowsie Oct 18, 2016

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

blowsie commented Oct 18, 2016

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

@webfacer

This comment has been minimized.

Show comment Hide comment
@webfacer

webfacer Nov 25, 2016

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?

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 comment has been minimized.

Show comment Hide comment
@jpierson

jpierson Mar 14, 2017

This section should be labeled Push the merged release branch.

This section should be labeled Push the merged release branch.

@morrismatts

This comment has been minimized.

Show comment Hide comment
@morrismatts

morrismatts May 4, 2017

This is great, thanks! I think your markdown tables got messed up though. They need some  s to keep the empty first table cell from collapsing. Here's a fork with the change: https://gist.github.com/morrismatts/246a1c6272dd7a8fc0ff7511b6c026fc

This is great, thanks! I think your markdown tables got messed up though. They need some  s to keep the empty first table cell from collapsing. Here's a fork with the change: https://gist.github.com/morrismatts/246a1c6272dd7a8fc0ff7511b6c026fc

@Leland

This comment has been minimized.

Show comment Hide comment
@Leland

Leland May 17, 2017

Or just use <br>s to keep all the code in one cell: https://gist.github.com/Leland/eae99114bcf5349e692f4aca63193775

Leland commented May 17, 2017

Or just use <br>s to keep all the code in one cell: https://gist.github.com/Leland/eae99114bcf5349e692f4aca63193775

@ubante

This comment has been minimized.

Show comment Hide comment
@ubante

ubante May 18, 2017

I've been using your gist for a while, so thanks. Another way to fix the spacing is to use a leading pipe: https://gist.github.com/ubante/0b7ff4933adb11c0c3de0166b8e5826c. Thanks again.

ubante commented May 18, 2017

I've been using your gist for a while, so thanks. Another way to fix the spacing is to use a leading pipe: https://gist.github.com/ubante/0b7ff4933adb11c0c3de0166b8e5826c. Thanks again.

@ilabacheuski

This comment has been minimized.

Show comment Hide comment
@ilabacheuski

ilabacheuski Jul 21, 2017

Bug git push origin feature/MYFEATURE - for sharing branch should be in another column
And so on. Every column is shifted

ilabacheuski commented Jul 21, 2017

Bug git push origin feature/MYFEATURE - for sharing branch should be in another column
And so on. Every column is shifted

@seb54000

This comment has been minimized.

Show comment Hide comment
@seb54000

seb54000 Oct 4, 2017

Thanks a lot for this gists, very useful.
Thanks @morrismatts or @Leland or @ubante for the fork solving the display problem with the leading space in the tables.

seb54000 commented Oct 4, 2017

Thanks a lot for this gists, very useful.
Thanks @morrismatts or @Leland or @ubante for the fork solving the display problem with the leading space in the tables.

@JamesMGreene

This comment has been minimized.

Show comment Hide comment
@JamesMGreene

JamesMGreene Nov 30, 2017

Wow, thanks for all the comments, everyone! Since GitHub never notifies of comments on Gists, I had no idea this one had become so popular until a friend of mine mentioned it coming up near the top of his Google search results for git flow initialize repository. Too funny!

Thanks for all the feedback. I've fixed the table markdown so the columns are correct again... that kind of thing happens every once in a while when GitHub decides to tweak their markdown rendering rules. 😕

Owner

JamesMGreene commented Nov 30, 2017

Wow, thanks for all the comments, everyone! Since GitHub never notifies of comments on Gists, I had no idea this one had become so popular until a friend of mine mentioned it coming up near the top of his Google search results for git flow initialize repository. Too funny!

Thanks for all the feedback. I've fixed the table markdown so the columns are correct again... that kind of thing happens every once in a while when GitHub decides to tweak their markdown rendering rules. 😕

@JamesMGreene

This comment has been minimized.

Show comment Hide comment
@JamesMGreene

JamesMGreene Nov 30, 2017

@sapeish Great tip on the --showcommands flag for git flow. I had no idea about that one but now I'll be curious to compare my assumptions to see how close I was [when I maybe find time... if ever 😛].

Owner

JamesMGreene commented Nov 30, 2017

@sapeish Great tip on the --showcommands flag for git flow. I had no idea about that one but now I'll be curious to compare my assumptions to see how close I was [when I maybe find time... if ever 😛].

@hyptechdev2015

This comment has been minimized.

Show comment Hide comment
@hyptechdev2015

hyptechdev2015 May 16, 2018

Thank you for putting this together, it helps me so much.
I also found this visually helpful, combine with @JamesMGreene's https://danielkummer.github.io/git-flow-cheatsheet/#features

hyptechdev2015 commented May 16, 2018

Thank you for putting this together, it helps me so much.
I also found this visually helpful, combine with @JamesMGreene's https://danielkummer.github.io/git-flow-cheatsheet/#features

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