⭐️ Lean Branching - a git branching model to keep clean history

· GitHub ·

3 min read Original article ↗

@DanPristupov i am very happy about your lean branching approach to be as simple as possible.
I have also thought about this major topic in git and let me give you my contribution from my approach called "nogit"
that is reduced to a set of git scripts associated with windows contextual menu.

Image

NB: in nogit update is your sync

Sync (rebase on master or fast-forward merge into master)

Of course sync as a pull-push operation is basic without conflicts...

Update from... (merge FROM master)

When several branches are concurrents, it is good to "refresh" the feature branch with the "master" that has been updated by other "finish feature". So the command "Update from" does the merge of master INTO the feature branch.
Of course, this is only straight forward without conflict.

Partial Merge and Conflicted Commit

In order to smoothly manage conflicts, nogit implements a conflict view ("show diff") to anticipate the merge and prepare conflict resolution by analysing auto-merged conflict and real conflicts.

Image

But the developer can also engage the merge to create a "conflicted commit" as a bounce of the conflicted branch.
This principle is applied for the "sync", the "update from" and the "finish feature".
Image
NB: here is a conflicted update after merging another branch

NB: for the sync, nogit create a "personal branch" after the bounce postfixed by the name of the developer (cf. branching naming convention)
Image

This commit contains all the files including the conflicted ones that are replaced by the diff result <<<< ====== >>>>

Image After this commit you have 2 auto-commits that restore respectively the state before the conflict on each branch (this preserve the topology of the DAG).

With that way, the conflicts are resolved little by little on the feature branch and finally merged with "--ours";
This is in my pov easer to manage than the interactive way (rebase or resolve)...

In addition, nogit defines somes conventions to ease history reading

Commit Naming Convention

It could be great to add a specific inputfield in the commit window to define a prefix for the commit (UPG, ADD, DEL, CLR, FIX, REN...)
Some specific prefix can be used : NEW, MRG, UPD, >|< (for conflicted commit)
Sometimes I use "!" to mark a critical commit that impacts major digit in semvers.

Image

Branching Naming Convention

Most of the time considering master is enough but for complex repo we can have some subfeatures...
Have you considered the very simple naming convention based on "motherBranch.subBranch"
Ex: master.sprintA.featureB

Branching Commit

In complex repo, the DAG can be "twisted" and we "loose" the rtack of master and feature branches when they are deleted.
An easy and good convention is to "start feature" with an empty commit "NEW branch"

Image

I hope that I am clear and that this will give you some ideas to improve your so great git client.
Don't hesitate to question or amend my proposition.