Branching Strategy - KnoldusLabs/codesquad-support GitHub Wiki

Main branches

There would be 2 main timeless branches at any given instance

1. master

2. develop

The release is always done from the master branch. The develop branch is the one on which all development changes are merged back.

Time based branches

At any given instance of time, there would be some time based branches. These would have a short time span and would be removed. We would discuss them one by one

###1. Feature branch

  • May branch off from: develop
  • Must merge back into: develop
  • Branch naming convention: anything except master, develop, release-, or hotfix-

This branch would be created for any new feature that we start working on. This could be a story OR a task under that story

Creating a feature branch

When starting work on a new feature, branch off from the develop branch.

$ git checkout -b myfeature develop

Switched to a new branch "myfeature"

Incorporating a finished feature on develop

Finished features may be merged into the develop branch definitely add them to the upcoming release:

$ git checkout develop

Switched to branch 'develop'

$ git merge --no-ff myfeature

Updating ea1b82a..05e9557 (Summary of changes)

$ git branch -d myfeature

Deleted branch myfeature (was 05e9557).

$ git push origin develop

Deleting remote branch

$ git push origin --delete myfeature

The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature.

###2. Release branch

  • May branch off from: develop
  • Must merge back into: develop and master
  • Branch naming convention: release-*

When we are ready to push code to production, we would create a release branch like this

$ git checkout -b release-1.2 develop

Once the release is made, the release branch is merged back into master and develop

$ git checkout master

Switched to branch 'master'

$ git merge --no-ff release-1.2

Merge made by recursive. (Summary of changes)

$ git tag -a 1.2

and

$ git checkout develop

Switched to branch 'develop'

$ git merge --no-ff release-1.2

Merge made by recursive. (Summary of changes)