DEV Community

Sagar Pandey
Sagar Pandey

Posted on

yet another git branching strategy

Overview

git branch management is something i am sure we all struggle.

Application which are platform dependent might face this problem quite frequently as the platform licensing restrict them to have unlimited dev environment which is not the case for open source dependent application. Thus git flow or trunk based approach doesn’t suit well here. I want to publish this approach to have a discussion/debate around it and if possible get a better suited approach which others are using. Burn the comments section for the same.

You are free to make a pass if you don’t fall under this scenario.

When there are multiple teams working on same git repository and the release plan is highly agile. ie. when story/feature will be deployed is not certain , in that case a master/main branch based approach results in minimum conflicts. I have named this master/main affinity based branches as “mainly”.

The core of this approach is to have a feature branch from main branch and merge it wherever needed till the lifecycle of the feature.

1. Regular Development Cycles

1.1 Working on features using master/main based branches

  1. Create a branch from master , name it feature/_FeatureName Ex: feature/58484_Login
  2. Raise a PR to Environment Branch Ex: UAT Branch or a release branch
  3. Run the pipelines from the Environment/Release branch.

feature branches

1.2 Conflicts resolution

  1. Create a intermediate branch from Environment branch

    Ex: UAT_featurename_Merge from release/UAT_BRANCH

  2. Merge your feature branch to Environment branch

    i.e. merge feature/login —> UAT_featurename_Merge

  3. Raise PR from intermediate branch to environment branch

    i.e. UAT_featurename_Merge —> release/UAT_BRANCH

  4. Successive changes can be directly PRed from feature to enviroment branch.

    i.e. feature/login —> release/UAT_BRANCH

conflict resolution

2. Moving to upstream environments (PROD)

Assume we have feature branches feature/login , feature/myProfile and feature/myContacts

Only login and myProfile are planned to be release to upstream environment.

  1. Create a release branch Ex: release/master_v1
  2. Raise PR and merge feature/login and feature/myProfile
  3. Raise a PR from release/master_v1 to main
  4. Run the pipelines either from main or if you want to stage your changes then stage it from release/master_v1

Moving upstream

Top comments (0)