Skip to content

Git Flow

Thomas Chen edited this page Aug 31, 2018 · 1 revision

Main Branches

  • master
  • develop

origin/master = HEAD is always production-ready
origin/develop = HEAD reflects latest delivered dev changes for next release  

Supporting Branches

  • feature branches
  • release branches
  • hotfix branches  

Git Flow and Commands

Notes

  • Remember github does not recognize new branches until they are pushed, make sure to push to origin before working on a new feature branch
  • Replace all X.x.x in commands below with appropriate version number
  • "git remote prune origin" to update local branches from upstream

Remove/Rollback Changes

git stash save --keep-index --include-untracked
git stash drop

Remove obsolete remote branches from local

git fetch -p

Fastforward older feature branch to be up-to-date with develop

git checkout feature
git merge --no-ff develop

Style and Conventions

General Naming Conventions

  • "-" for spaces
  • Keep it short
  • Active tense for commit messages
  • Commit messages should start with a single word identifier followed by - message such as core - add classifier lambda to lambda state machine  

Feature Branches

Use token based naming convention

  • bug/* - bug fixes
  • feat/* - new or expanding features
  • wip/* - long term works in progress
  • junk/* - throwaway
  • infra/* - infrastructure, refactor, cicd, etc  

Hotfix Branches

Use short description of the fix/bug for naming such as psycopg2-dep-fix  

Release Branches

Follow Semantic Versioning standards (X.x.x)  

X.y.z
X = MAJOR version when you make incompatible API changes
y = MINOR version when you add functionality in a backwards-compatible manner
z = PATCH version when you make backwards-compatible bug fixes.

Feature Branch

Create a feature branch

git checkout -b myfeature develop

  Incorporating a finished feature on develop

git checkout develop
git merge --no-ff myfeature
git branch -d myfeature
git push origin develop

Release Branch

Creating a release branch

git checkout -b release-X.x develop
./bump-version.sh X.X
    NOTE: bump-version.sh doesn't exist, it is a placeholder for "changing everything that needs to be changed 
          for next release (i.e., replace all strings that say verion Y.y with x.x)
git commit -a -m "Bumped version number to X.x"

Finishing a release branch

git checkout master
git merge --no-ff release-X.x
git tag -a X.x
    NOTE: -s to sign the tag cryptographically
git checkout develop
git merge --no-ff release-X.x
git branch -d release-X.x

Hotfix Branch

Creating a hotfix branch

git checkout -b hotfix-X.x.x master
./bump-version.sh X.X
    NOTE: bump-version.sh doesn't exist, it is a placeholder for "changing everything that needs to be changed for 
          next release (i.e., replace all strings that say verion Y.y with x.x)
git commit -a -m "Bumped version number to X.x
git commit -m "Fixed severe production problem"
    NOTE: Do this after actually fixing the bug

Finishing a hotfix branch

git checkout master
git merge --no-ff hotfix-X.x.x
git tag -a X.x.x
    NOTE: -s to sign the tag cryptographically
git checkout develop
git merge --no-ff hotfix-X.x.x
git branch -d hotfix-X.x.x