Source Control

2 min. read

Introduction

We use Git with BitBucket or Github, depending on the client.

We use SourceTree for GUI Git Client.

Branches

We use Git Flow for our Git workflow (built into SourceTree)
Initialize the repository with Repository -> Git flow/Hg flow -> Initialize Repository
Main Branches
Only main branch are required for most projects.
master
production-ready
develop
integration branch, nightly builds. Once develop is stable, it should be merged back into master and tagged with the version number.

Supporting Branches
These branches will be removed.
feature
Branch from develop
Merge back into develop
Naming convention feature-NAME

Also called topic branch

Use this branch to test new features, if successful, merge back into develop, if not, discard it.

Create a feature branch
git checkout -b FEATURE develop

Merge:
git checkout develop
git merge --no-ff FEATURENAME
git branch -d FEATURENAME
git push origin develop

release
Branch from develop
Must merge back into develop or master
Naming convention: release-x.x.x

This branch is for preparing for release, like release dates and versions

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

Minor small changes can be done in the release branch.

Finish release branch
git checkout master
git merge --no-ff release -1.2
git tag -a 1.2
git checkout develop
git merge --no-ff release-1.2
git branch -d release-1.2
hotfix
Must branch from master
Must merge back into develop and master
Naming convention: hotfix-xxxx

These branches are meant for immediate bug fixes of critical bugs in production. This allows develop to continue while the the fix is implemented.

References
https://medium.com/@budioktaviyans/how-to-make-a-git-flow-using-sourcetree-20ab77fe6813
https://git-scm.com/book/en/v2