Calculate the average lifetime of feature branches from creation to merge.
Branch lifetime tracks how long feature branches stay open before merging or being deleted. Formula: avg_lifetime = sum(branch_durations) / branches. Long-lived branches accumulate more divergence from the base, raising merge conflict risk and making code review harder — trunk-based development practices explicitly target very short branch lifetimes (hours to a couple of days).
avg_lifetime_days = sum_of_branch_durations / branch_count
Trunk-based development teams often target under 1-2 days; many mainstream teams target under a week. Beyond 2 weeks, divergence and conflict risk climb sharply for most codebases.
Compare the branch's first commit timestamp (or creation event from your Git host's API) to its merge or deletion timestamp. GitHub/GitLab APIs expose PR creation and merge times directly, which is usually a cleaner proxy.
The longer a branch lives, the more the base branch moves on without it — increasing both the volume of changes to review at once and the odds that the same files were touched on both sides, causing conflicts.
Smaller PRs scoped to a single change, feature flags to merge incomplete work safely, and fast CI/review turnaround all reduce how long a branch needs to stay open before merging.