Skip to content

Instantly share code, notes, and snippets.

@stuartsaunders
Forked from zaach/workflow.md
Created June 22, 2010 05:07
Show Gist options
  • Save stuartsaunders/448036 to your computer and use it in GitHub Desktop.
Save stuartsaunders/448036 to your computer and use it in GitHub Desktop.
Versioning and Git Workflow

Semantic Versioning

Details: http://semver.org/, http://apr.apache.org/versioning.html

Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR versions retain source and binary compatibility with older minor versions, and changes in the PATCH level are perfectly compatible, forwards and backwards.

Patch level changes could also be for correcting incorrect APIs. In this case, the previous patch release may be incompatible, but because of bugs.

Minor versions may introduce new features, but do not alter any of the previous API.

Major versions may introduce new features and change the old API in incompatible ways.

Git workflow

Details: http://nvie.com/archives/323/ Helpful scripts: http://github.com/zaach/gitflow

The different types of branches we may use are:

  • master

    • production releases
  • develop

    • AKA integration branch
  • Release branches (release-*)

    • for finalizing a major/minor release, branched from develop
  • Hotfix branches (hotfix-*)

    • for applying patches, branched from master (or support-* for older releases)
  • Support branches (support-*)

    • for applying patches to old release versions, branched from master
  • Feature branches (feature-*)

    • for developing features or wild speculation, branched from develop

Feature branches

Created for feature development that may require several or more commits to produce a working tree. May make occasional merges from develop to keep it up to date. If it will be separate for an extended period of time, create a feature-branch-readme.txt in the top level directory dictating the reason for the branch.

May branch off from: develop

$ git checkout -b myfeature develop

Must merge back into: develop

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

Release branches

Release branches are created when the develop branch is at a stable point and release specific changes need to be made, such as bumping version numbers, etc. At that point, develop should be branched and the changes made before ultimately merging it into master and tagging the release. There should only be one active release branch at a time. Until the current release is wrapped up, merged into master and deleted, development of the next release should take place on develop. When develop reaches another state of stability for release, another release branch is be created.

May branch off from: develop

$ git checkout -b release-1.2 develop
$ ./bump-version.sh 1.2
$ git commit -a -m "Bumped version number to 1.2"

Bug fixes made on a release branch may be merged back into develop continuously if needed, though ultimately they will be merged in when the release is finalized.

Must merge back into: develop and master

$ git checkout master
$ git merge --no-ff release-1.2
$ git tag 1.2

$ git checkout develop
$ git merge --no-ff release-1.2

# Comment about WHY we delete the release branch.
# What to do about the REMOTE copy of the release branch.  Delete it?  how are other downstream copies of this branch effected?
$ git branch -d release-1.2

Hotfix branches

Patches that need to be made to the most recent production release are applied to a hotfix branch off master. For older releases, hotfixes branch off a support-* branch (explained later.)

May branch off from: master

$ git checkout -b hotfix-1.2.1 master
$ ./bump-version.sh 1.2.1
$ git commit -a -m "Bumped version number to 1.2.1"

$ git commit -m "Fixed severe production problem"

Must merge back into: develop and master

$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag 1.2.1

Merge into develop only if there is no current release branch, otherwise, merge into release branch instead.

$ git checkout develop
$ git merge --no-ff hotfix-1.2.1

Finally, delete. $ git branch -d hotfix-1.2.1

Support branches

If master has moved on a point release (1.0, 1.1, 2.0, etc) and a hotfix must be applied to a older version ( e.g 1.x):

  • create a support-1.x branch (if none exists) based on the newest 1.x tag in master
  • create a branch (e.g. hotfix-1.1.1), based on support-1.x
  • fix the bug and merge hotfix-1.1.1 back into support-1.x
  • Do this for other older major releases as necessary

The support branch effectively becomes a master branch for a past version.

Create a few small pictures showing what the tree looks like after a few releases/hotfixes, etc. Maybe one or two visuals to help support.

@jeosol
Copy link

jeosol commented Nov 19, 2017

Very nice.

Thanks for illustrating how to do this with details. Most time I search for this, I just see diagrams of how the different
branches are connected but not how to actually go about checking out and merging each one.

Cheers.

@mikecabana
Copy link

This is exactly what I was looking for. The images seem to be broken though. Any chance of fixing them?

@krzepah
Copy link

krzepah commented Jul 1, 2018

Thanks

@abcdenis
Copy link

abcdenis commented Jun 8, 2020

Missed

git push origin develop
git push origin master
git push --tags origin

at the end of Release branches

@tisdall
Copy link

tisdall commented Sep 9, 2020

@press0
Copy link

press0 commented Jul 3, 2021

github.com strongly recommends feature branches be created off main NOT develop:

There's only one rule: anything in the main branch is always deployable. Because of this, it's extremely important that your new branch is created off of main when working on a feature or a fix.

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