Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 21, 2022 08:59 am GMT

An overview of some Git branching models

Git is a wonderful tool. But like all tools, it require methods to be used correctly. This article will cover some git branching model I have encountered in my career.

Trunk Only Development

Used either by student who dont know what they are doing or by skilled and mature team as an extreme interpretation of Trunk Based Development.

Trunk Only Development branching model

Pros:
Real time integration.
Makes developers aware of their responsibilities: If you break something, everyone is impacted.

Cons:
When a commit break something, everyone is impacted
Dont forget to pull before pushing.
Quickly becomes a real mess if your team is not mature enough. Even if history stay linear, your product will be broken several times a day and developers will spend lot of time fixing conflict.

One branch per developer

If you dont know what to do, take this one. Simple to explain, very well adapted to Githubs Pull Request or Gitlabs Merge Request paradigm, and ensure some stability even with beginners team.

One branch per developer branching model

Pros:
Master branch always works.
No integration dependency. Each developer is responsible of its own branch.

Cons:
Isolate developer on its own task.
No validation of branches together.
Require well dimensioned test infrastructure. May not be possible for embedded development or heavy legacy software.

One branch per feature

Similar to the one before, but enforce collaboration between developers. For me, the best trade off between having real time integration and having a stable Master branch.

One branch per feature branching model

Pros:
Master branch always work.
No integration dependency.
Several developers can work on the same feature.

Cons:
No validation of branches together.
Require good collaboration between developers.
Require well dimensioned test infrastructure. May not be possible for embedded development or heavy legacy software.

Trunk Based Development

This one seems to be the most fashionable model today. Warning, Trunk Based Development is not Trunk Only Development. Developers can work both on master branch for small fixes or on feature branches for more complex development, as long as feature branches have a short lifetime. You can take a look to this article to have more details about this model.

Trunk Based Development branching model

Pros:
Benefit of real time integration and longer term development
Empower collaboration and accountability.

Cons:
Master can be broken
High and variable pressure on test system => Require a dynamic scalable infrastructure.
Risk of drifting to Trunk Only Development by laziness.

Nightly integration test

Developer merge their branch in a Nightly test branch. Test are executed nightly and result are available in the morning. If you dont have a very exotic test system with strong constrains that prevent you doing real continuous integration, please dont do this.

Nightly integration branching model

Pros:
Branch are validated together.
Load is constant on test infrastructure.
Can handle complex test system or very long tests.

Cons:
Have to wait the next day to have results.
If test infrastructure crash during the night, have to wait another day.
When test fail, have to investigate which branch is responsible.

Gitflow

Gitflow has a little success back in the 2015s, especially with the git-flow CLI tool. It is today more and more criticized for its complexity and the latency it introduced in integration. What I personally think about Gitflow can be summarized by:

Just because you are doing something complicated doesnt mean you are doing something smart.

Gitflow branching model

Pro:
Explicitly handle all the case than can occurs during product life time: Feature development, stabilization, code freeze, last minute hotfixes.
Each branches are tested before integration and common result is tested before release.

Cons:
Complicated to explain for people who are not familiar with Git.
Lot of branches, lot of complexity, lot of mistakes.
Going from feature to master takes times, slowing down continuous integration.

Guitar hero world tour

Guitar hero world tour branching model

Pro:
Very good with friends

Cons:
Is not a branching model


Original Link: https://dev.to/tandrieu/an-overview-of-some-git-branching-models-3ilj

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To