Skip to content

Instantly share code, notes, and snippets.

@JamesMGreene
Last active April 30, 2024 14:11
Show Gist options
  • Save JamesMGreene/cdd0ac49f90c987e45ac to your computer and use it in GitHub Desktop.
Save JamesMGreene/cdd0ac49f90c987e45ac to your computer and use it in GitHub Desktop.
`git flow` vs. `git`: 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

@MuhammadSawalhy
Copy link

MuhammadSawalhy commented Aug 28, 2020

Why is a colon here?
git push origin :release/1.2.0

@giovannipds
Copy link

@ms2052001 does this answer your question? But I'd say test it in a scenario you wouldn't lose something.

@peterblazejewicz
Copy link

IMO, finishing a feature should read:

git merge --ff feature/MYFEATURE

not --no--ff

Can be verified with --showcommands

git flow feature finish MYFEATURE --showcommands

@Thorsten-C
Copy link

@peterblazejewicz, the thing here is that features finished consisting of a single commit, it does a --ff.
A feature finish with multiple commits does a '--no-ff'.
Not sure why.
Imo --no-ff is preferred for tree-readablity and uniformity.

@time4Wiley
Copy link

Why there is colon here?
git push origin :release/1.2.0

colon is specified to delete the branch from remote origin.

@magneticcore
Copy link

Hi,

If a release has been created as release/1.1.0, how can we bring minor changes on it, in term of branching?
I mean, do we need to create a branch like fix/XXXX coming from release/1.1.0 to do our changes and after merging back to release/1.1.0?

Or what is the best pratices to put our changes in release/1.1.0?

@jauninp
Copy link

jauninp commented May 24, 2023

Hi,

To create a Feature or a Release before th command git checkout -b feature/MYFEATURE develop
it wouldn't be better to do a "pull" before ? like :

git checkout develop
git pull origin develop

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