git-contrib-tree

A repository's file tree, with the top contributors to each file.

Who to ask about which file.

Git toolsCLIPythonv0.2.1, MIT / WTFPL

$ uv tool install git-contrib-tree

What it is

A file tree of the repository, with the top three contributors and their commit counts next to every file and directory. Directory numbers are aggregated from everything below them. It's for finding the person who knows a file, or for spotting parts of the codebase that only one person has touched.

Repository: my-repository

├── README.md - John Doe (5), Jane Smith (2)
├── src/ - John Doe (48), Jane Smith (23), Bob Johnson (10)
│   ├── main.py - John Doe (25), Bob Johnson (10), Jane Smith (3)
│   └── models/ - Bob Johnson (20), John Doe (15), Jane Smith (5)
└── tests/ - Jane Smith (12), John Doe (8), Bob Johnson (2)

How it works

git ls-files provides the tracked files, which are built into a tree in memory. One git log --name-only call then provides every commit and the files it touched, so all files are counted in a single pass. Directories are summed bottom-up. --depth only limits what is printed: a directory summary still counts every file below it.

By default only the last three months are counted. --since -1 counts the whole history.

git contrib-tree --depth 0
git contrib-tree src --since "6 months ago" --depth 2
git contrib-tree --email user@example.com
git contrib-tree --list-emails

Install

It uses only the Python standard library and git, and works as git-contrib-tree or as the git subcommand git contrib-tree. It is on PyPI (uvx git-contrib-tree, pip install git-contrib-tree) and the AUR. The script is a single self-contained file, so you can also download and run it directly. The README notes that LLMs helped write the code and the documentation.