GIT Branching Strategy

  GIT

  • Starting a new project

Create project specific branch from develop branch

git checkout develop
git pull
git checkout -b project-<JIRA Name>

Name it after your JIRA project name, for example the newsletters project would name their branch project-new.

This branch should live through the entirety of your project.

  • Start working on a ticket for project

When starting a new ticket, branch off of the project branch.

git checkout project-<JIRA Name>
git pull
git checkout -b <JIRA Ticket number>
  • Work on ticket is complete

Merge project branch into your ticket to make sure there are no conflicts, do pull request and code review

git pull origin project-<JIRA Name>
git pull
git checkout <JIRA Name>
git pull
git merge project-<JIRA Name>
#push to origin and do pull request
  • QA is ready to test project

We need to merge the develop branch into the project to pickup changes from other projects that have been released and make a release branch for QA, make sure you fix any merge conflicts along the way.

git pull origin develop
git checkout project-<JIRA Name>
git pull
git merge develop
git checkout -b project-<JIRA Name>-release
#push to origin and build release from this branch for QA to start testing
  • QA finds a bug in the project, we need to create a hotfix for the project release branch
git checkout project-<JIRA Name>-release
git pull
git checkout -b <JIRA Ticket number>

– fix the issue and create a pull request against project-<JIRA Name>-release, once it passes code review it will be merged into project-<JIRA Name>-release and QA can resume testing.

  • QA is happy with project-<JIRA Name>-release

We need to update develop and release and all project branches with project changes

git pull origin project-<JIRA Name>-release

git checkout develop
git pull
get merge project-<JIRA Name>-release # merge into develop branch
#push to origin and merge develop into all project branches and release branch
  • Project is deployed to production

Once deploy is complete, merge release into master

git pull origin release
git checkout master
git pull
git merge release
#push to origin