Skip to content

Instantly share code, notes, and snippets.

@lantrix
Created April 5, 2019 02:10
Show Gist options
  • Save lantrix/ae058ee4b36a8972df7e30285f002beb to your computer and use it in GitHub Desktop.
Save lantrix/ae058ee4b36a8972df7e30285f002beb to your computer and use it in GitHub Desktop.
Git Flow workflow

Git-Flow Cheatsheet

Initialize a Repository for git-flow

git flow init

Follow along:

Which branch should be used for bringing forth production releases?
   - develop
   - dummy
   - master
Branch name for production releases: [master]

Which branch should be used for integration of the "next release"?
   - develop
   - dummy
Branch name for "next release" development: [develop]

How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? [v]

Features

Features usally one per card.

Start a New Feature

This creates a new branch based on develop and switches to it:

git flow feature start FEATURENAME

Publish a Feature

Push a feature branch to github.com:

git flow feature publish FEATURENAME

Get a feature published by another Dev from github.com:

git flow feature pull origin FEATURENAME

Example of starting/publishing a feature

This creates a feature branch and publishes it for others to work on:

$ git pull
Already up-to-date.

$ git flow feature start my-new-thing
Switched to a new branch 'feature/my-new-thing'

Summary of actions:
- A new branch 'feature/my-new-thing' was created, based on 'develop'
- You are now on branch 'feature/my-new-thing'

Now, start committing on your feature. When done, use:

     git flow feature finish my-new-thing

$ git flow feature publish my-new-thing

Total 0 (delta 0), reused 0 (delta 0)
To ssh://[email protected]:lantrix/test.git
 * [new branch]      feature/my-new-thing -> feature/my-new-thing
Already on 'feature/my-new-thing'
Your branch is up-to-date with 'origin/feature/my-new-thing'.

Summary of actions:
- A new remote branch 'feature/my-new-thing' was created
- The local branch 'feature/my-new-thing' was configured to track the remote branch
- You are now on branch 'feature/my-new-thing'

$ git checkout develop
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
$ git checkout feature/my-new-thing
Switched to branch 'feature/my-new-thing'
Your branch is up-to-date with 'origin/feature/my-new-thing'.

Finish a Feature

This merges the feature into develop, removes the feature branch, and switches to develop:

git flow feature finish FEATURENAME

Releases

Start a Release

Create release branch from develop:

git flow release start RELEASENAME

Publish release branch:

git flow release publish RELEASENAME

Create a local tracking branch for a remote release:

git flow release track RELEASENAME

Example Release

Create a release; publish it and add a commit. Adding the commit causes the CI build to kick off automatically

git flow release start 1.0.0
git flow release publish 1.0.0
vim Readme.md
git commit -a -m "Release 1.0.0 Preparation"
git push

Finish a Release

Merge release branch into master, tag it, merge back into develop, and remove the release branch:

git flow release finish RELEASENAME
git push --tags

Hotfixes

Start a Hotfix

Create hotfix branch from master:

git flow hotfix start VERSIONNAME

Create hotfix branch from some other commit:

git flow hotfix start VERSIONNAME BASENAME

Finish a Hotfix

Merge hotfix back into develop and master, and tag:

git flow hotfix finish VERSIONNAME

References

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