gitflow is a git branching methodology that Vincent Driessen created and has been adopted by many companies with great success. Atlassian even covers gitflow in their git tutorials.
master
master
is master. ;) It will have anything that is in production.
develop
This branch for the most part parallels
master
and is kept up-to-date.
feature/{feature_name}
This branch contains a new feature to be introduced within the codebase.
release/{version_number}
This branch is prepared after feature, bugfix, et cetera branches are merged into the
develop
branch. Essentially, a release is prepared after a developer finishes work in dev and is ready to have it sent to QA.
hotfix/{hotfix_name}
This branch is used for any bugfixes that are usually found after a release that are necessary to be rolled out as top priority.
bugfix/{bugfix_name}
Bugfix branches are coupled with release/* branches. During QA if there are bugs that need to be addressed, a bugfix branch will be used to merge into the release branch and the develop branch.
These are the typical environments that are used within any sofware development cycle.
Dev
develop
QA
Production
New feature during a sprint/dev-cycle
Development on a new feature will start by branching off of the
develop
branch. After development is complete, thefeature
branch is merged back into the develop branch.** Note:
feature
branches do not get deleted until the release it will be in gets merged intomaster
Creating a release
After all of the development on any feature branches are complete and they are merged back into the develop branch, you can branch off of the
develop
branch to create arelease
branch.At this stage is where you will decide on the version number and also begin QA.
Bugfix found during QA
A
bugfix
branch is used to address any bugs found during QA. This branch is created by branching off of the respectiverelease
branch from which the bug was found.After development is complete, the
bugfix
branch gets merged back into its respectiverelease
branch and thedevelop
branch.Creating a hotfix
A
hotfix
branch is created by branching off ofmaster
or the latesttag
. So essentially, whatever is live in production already. A version bump can be done in thehotfix
branch in lieu of creating arelease
branch.Tagging
A tag is created after the
release
branch is QA'd and merged intomaster
.
Two developers, same codebase
During a sprint/dev-cycle, two developers need to work on features that are in the same codebase. Both developers clone the repository and both create their respective branches off of the latest
develop
branch.After the
feature
branches are done, they are merged back intodevelop
.A
release
branch is created by one person who will branch off ofdevelop
since it has all of the completed features.The
release
branch can now be sent over for QA.After QA passes, a production rollout can take place; the
release
branch can be merged intomaster
anddevelop
.Bug found in QA
During QA, if a bug is found, a
bugfix
branch can be created by branching off of therelease
branch in which the bug came from. Thebugfix
branch is then merged into therelease
branch again.Critical bug found after production rollout
If a bug has been found after a release has been rolled out in production and development has already started for another dev-cycle, a
hotfix
branch can be used.The
hotfix
branch branches off ofmaster
(or the latest tag). After development is done, thehotfix
branch gets merged intomaster
anddevelop
.Other development in the dev-cycle can continue as normal since the
hotfix
branch is branched off ofmaster
.Cherry picking features
As mentioned earlier,
feature
branches do not get deleted until therelease
branch they are in are merged intomaster
. Keeping these branches around until then allow features to be cherry picked.There will be some instances where some features need to be delivered faster than others. In this case, it would be suitable to create a release with only the features wanted; the remaining features can be released in another
release
branch.