DEV Community

Git Branching and Branching Strategy

Preetham on July 09, 2020

In this post, we will go over why branching is required, the difference between development, staging and production environments, why a strategy is...
Collapse
 
ryanbuening profile image
Ryan Buening

How do you handle hotfixes into master/production if the develop/staging branch has changes (maybe new features) that cannot be pulled into production yet?

Collapse
 
preethamsathyamurthy profile image
Preetham

Though not a frequent occurence and should be avoided, but in those specific scenarios, we can create a new branch from master, test the hotfix and create a pull request to master which should be validated and approved by people other than the dev who makes the change.
P.S.
Do suggest a methodology incase you have something in mind

Collapse
 
shvahabi profile image
Shahed

Oh not acceptable, since you mess up with master branch. My methodology is to have another permanent branch release which can serve as source/target of hotfixes.

Collapse
 
shvahabi profile image
Shahed

A very good and through introduction to conventional branching strategy; however I didn't find a notion of hotfixes here. hotfixes are different from bugfixes, they come from production/testing team and customer issues respectively. Considering hotfixes, then some modification should be applied to suggestions made here. Other than master, another branch should be available called releases. This branch will be source and target of hotfix/ branches between two minor/major releases and deliver not-fully-tesed fixes to customer under a new patch releases (in semver we've got major, minor and patch increments).

The idea is customer should not wait for a planned next release, but fixes should be instantly available, even without covering all test cases. Hence such a patch increment will not announce to all customers but only the affected ones. But all such fixes should be transferred or re-implemented into development to mature in routine life cycle of production including coverage test. Then release branch will be updated by next major/minor increment from stable while it has all such hotfix counter measures already included.

Another issue I found with your article is that you did not distinguish temporary branches from permanent ones.

Collapse
 
valentinprgnd profile image
Valentin Prugnaud 🦊

This strategy has been proven to be an anti-pattern though, for more on this: martinfowler.com/articles/branchin...

Collapse
 
bnevis profile image
Bryon Nevis

I disagree with that assessment. The anti-pattern originates from "An environmental branch is branch that contains commits that apply to the source code to reconfigure the product to run in a different environment." The suggested branching model, when no changes are being made to development, will eventually result in development, staging, and production being absolutely identical.

Collapse
 
bestscarper profile image
Ashley Hindmarsh

You don't explain why the dev is making multiple commits for a feature (e.g. footer).
Branching is powerful but not the only paradigm.

Collapse
 
preethamsathyamurthy profile image
Preetham

I agree with you that branching is not the only paradigm. I am just explaining about the branching strategies and good practices to follow and there's a saying that start the day with a pull and end the day with a push to prevent any loss of code. So as you say, footer is just an example and consider a big feature !

Collapse
 
arapmahir profile image
the_mahir

Hello,
What does this sentence mean: "In a huge project involving many users, a single feature, depending on the need, can be worked by many users." from huge project with many users section. Can anybody explain me please?

Collapse
 
arapmahir profile image
the_mahir

The user context over there means as a developer right? Multiple developers(users) working on the same feature, not the user that is when the code is live.

Collapse
 
dev-i-am profile image
Derek

why would you branch new features from develop? that means you are bringing in untested code from others that may not even make it to production.