Skip to content
ENExplore Calculators

Branch Divergence Calculator

Calculate how many commits two Git branches have diverged from a common ancestor.

About Branch Divergence Calculator

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

Worked example

With the default values below, Branch Divergence Calculator returns Total Divergence of 42. Change any input above and every figure here is recalculated in your browser.

Inputs used

Commits Aheadaccepts 0–100,000 commits
12 commits
Commits Behindaccepts 0–100,000 commits
30 commits
Files Touched by Both Sidesaccepts 0–100,000 files
8 files

Results

Total Divergence
42 commits
Merge Complexity
Moderate
Complexity Score
67 /100
Behind-to-Ahead Ratio
2.50

Step by step

  1. 1Divergence: ahead + behind= 42 commits
  2. 2Behind-to-ahead ratio= 2.50
  3. 3Complexity score (base + overlap)= 67

Assumptions and limits

  • The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 2 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

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).

Branch Divergence Calculator – Calculate Total Divergence