Show Menu

A successful Git branching model Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.


The main branches

master is the main branch in which the source code of HEAD always has a produc­tio­n-ready state.
develop is the main branch in which the source code of HEAD always represents a state with the latest develo­pment changes shipped for the next release.
Each time when changes are merged back into master, this is a new production release by defini­tion. We tend to be very strict at this, so that theore­tic­ally, we could use a Git hook script to automa­tically build and roll-out our software to our production servers everytime there was a commit on master.

Create a develop branch

git checkout -b develop
git push origin develop

Creating a feature branch

git checkout -b myfeature develop

Incorp­orating a finished feature on develop

git checkout develop
switch to branch 'develop'
git merge --no-ff myfeature
git branch -d myfeature
Deleted branch myfeature
git push origin develop

Creating a release branch

git checkout -b releas­e-1.2 develop
switch to a new branch "­rel­eas­e-1.2"
./bump-v­ers­ 1.2
Files modified succes­sfully, version bumped to 1.2.
git commit -a -m "­Bumped version number to 1.2"
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insert­ion­s(+), 1 deleti­ons(-)