Skip to content
Calcrivo

Branch Divergence Calculator

Measure how far a branch has diverged from its base using commits ahead and behind, and estimate merge complexity.

Inputs

commits

Commits on this branch not yet on the base branch.

commits

Commits on the base branch not yet merged into this branch.

files

Files modified both on this branch and on the base since divergence.

Total Divergence

42commits

Merge Complexity

Moderate

Complexity Score

67/100

Behind-to-Ahead Ratio

2.50

Step by step

  1. Divergence: ahead + behind

    12 + 30

    = 42 commits

  2. Behind-to-ahead ratio

    30 / 12

    = 2.50

  3. Complexity score (base + overlap)

    f(divergence) + 8 × 1.5

    = 67

How it works

Divergence quantifies how far two branch tips have drifted apart. Formula: divergence = commits_ahead + commits_behind, as reported by `git rev-list --left-right --count base...branch`. A branch with many commits behind is at higher risk of conflicting with recent base changes; combining divergence with the count of files touched on both sides gives a rough merge complexity score.

Formulas

Total divergence

divergence = commits_ahead + commits_behind

commits_ahead
Commits on feature branch not on base
commits_behind
Commits on base branch not on feature

Merge complexity score

complexity_score = clamp(base_score_from_divergence + files_touched_by_both × 1.5, 0, 100)

base_score_from_divergence
Score derived from total divergence tier
files_touched_by_both
Files modified on both sides since divergence

Frequently Asked Questions

How do I get ahead/behind counts in Git?

Run `git rev-list --left-right --count origin/main...my-branch` — it prints two numbers: commits only on main (behind) and commits only on my-branch (ahead).

Why does 'commits behind' matter more than 'commits ahead'?

Being behind means the base has moved on without you, increasing the odds that files you're touching have also changed upstream — the primary source of merge conflicts, not raw commit count.

What's a safe threshold before I should rebase?

Many teams treat 20-50 commits behind as a signal to rebase or merge from base soon; beyond that, conflict risk and review complexity both climb sharply.

Does divergence alone predict merge conflicts?

No — divergence measures drift over time, while actual conflict risk depends on whether the same files/lines were touched on both sides (see the merge conflict probability calculator).

You might also need