Glossary · Git history

What is code ownership?

Code ownership is the person or team who wrote, maintains and is accountable for a piece of code. It can be declared, as in a CODEOWNERS file, or measured from version control as the author with the largest share of a file's lines or commits. Measured ownership shows who actually knows the code.

Last reviewed: November 2026

Also called File ownership, Code authorship, Primary owner

In depth Code ownership and bus factor from git: the full method, edge cases and what to do about a bus factor of 1.

How code ownership is measured

Two measures are in common use, and they answer different questions.

  • Line ownership: each author's share of the lines that exist today, from git blame. It shows who wrote the current code.
  • Commit ownership: each author's share of the commits that touched the file. It shows who maintains it.

Example for billing/invoice.py (500 lines, 50 commits):

AuthorLines (blame)Commits
Priya60%41
Sam30%6
Lee10%3

Priya is the owner by both measures here. The two can split: someone who rewrote the file in one large commit holds most lines but few commits. A recent owner, the most active author over the last 90 days, can also differ from the all-time owner.

Why code ownership matters

Ownership tells you who to ask, who should review, and where knowledge is concentrated. Bird, Nagappan, Murphy, Gall and Devanbu, "Don't Touch My Code! Examining the Effects of Ownership on Software Quality" (FSE 2011), studied Windows Vista and Windows 7 and found that components with many low-ownership contributors had more pre-release and post-release failures. The practical reading: someone should clearly own each important file, and a second person should be able to maintain it (see bus factor).

Declared and measured ownership drift apart. People leave, teams reorganise, and a CODEOWNERS entry keeps naming them. Measured ownership shows the drift.

How to measure code ownership yourself

# Who owns the lines that exist now
git blame --line-porcelain billing/invoice.py | grep '^author ' | sort | uniq -c | sort -rn

# Who made the commits
git shortlog -sn --no-merges -- billing/invoice.py

Add -w and -M to git blame to ignore whitespace changes and detect moved lines. git-fame summarises line ownership per author for a whole repository. CODEOWNERS is the right tool when you need enforced review: GitHub and GitLab read it to require approvals from named owners. The code ownership tools roundup compares measured-ownership tools.

How repowise measures code ownership

During git indexing repowise records per file a primary owner, a recent owner and the top authors.

  • Primary owner: the author with the largest share of current lines from one git blame --line-porcelain pass (files up to 100 KB, best effort). primary_owner_line_pct is their line share and primary_owner_commit_pct their share of the file's commits. If blame is unavailable, the author with the most commits is used. Pure file moves do not count as authoring.
  • Recent owner: the top author over the last 90 days and their share of recent commits.
  • Fading ownership: a code health detector fires when a file is still changing, has bus factor 1, and its primary owner is not the recent owner or contributes under 20% of recent commits. Stable files never fire it.
  • Suggested reviewers: a score that blends ownership of the touched files (weight 1.0), ownership of their co-change partners (0.5) and recent activity (0.4). See temporal coupling.
  • CODEOWNERS: repowise parses GitHub and GitLab CODEOWNERS files, so declared and measured owners can be read side by side.

Owners appear in get_context and get_risk over MCP and in repowise context <file>. They come from git, with no model involved. See git intelligence.

FREQUENTLY ASKED

Code ownership: questions

What is the difference between CODEOWNERS and measured code ownership?

CODEOWNERS is a file that declares who must review changes to a path. Measured ownership is computed from git history and shows who actually wrote and changes the code. They disagree often, and the gap is useful: a path owned on paper by a team that never commits to it is a stale entry.

How do you find the owner of a file?

Run git blame --line-porcelain on the file and count lines per author, or run git shortlog -sn on the file's history. The first gives who wrote the lines that exist now, the second who made the most commits.

Is strong code ownership good or bad?

Research on Windows found that components with many minor contributors had more failures (Bird et al., FSE 2011), which argues for clear owners. A single owner is a knowledge risk, which is why ownership is read together with bus factor.

Is code ownership the same as bus factor?

No. Ownership names who holds most of the code. Bus factor counts how many people it would take to cover most of the changes. A file can have a clear owner and a bus factor of 1, or a spread of authors and a bus factor of 3.

See it on your own repository.

Index a repository free and read the result for your own code and history. Rolling it out to a team? We will walk you through it.