git-fame
Show contribution statistics per file
TLDR
Calculate contributions for the current Git repository
Exclude files/directories that match the specified regex
Calculate contributions made after the specified date
Display contributions in the specified format
Display contributions per file extension
Ignore whitespace changes
Detect inter-file line moves and copies
Detect intra-file line moves and copies
SYNOPSIS
git fame [--sort=key] [--email] [--since=date] [--until=date] [--by-file] [--branch=name] [--exclude=pattern] [--incl-merges] [--csv] [--cost] [--loc] [--whitespace] [file_pattern...]
PARAMETERS
--sort=key
Sort the output by the specified key. Common values include lines (default), commits, or files.
--email
Display authors' email addresses instead of their names.
--since=date
Limit commits to those made after the specified date.
--until=date
Limit commits to those made before the specified date.
--by-file
Display contributions grouped by file instead of by author.
--branch=name
Specify the branch to analyze. Defaults to the current branch.
--exclude=pattern
Exclude files matching the given pattern from the analysis. Can be used multiple times.
--incl-merges
Include merge commits in the analysis. By default, merge commits are often ignored to prevent inflated line counts.
--csv
Output the results in Comma Separated Value (CSV) format, suitable for programmatic parsing.
--cost
Include the 'cost' of file renames and moves in the line counts, treating them as changes.
--loc
Use raw lines of code (LOC) count instead of unique lines of code, which might subtract lines on deletion.
--whitespace
Ignore whitespace differences when comparing file versions, focusing only on substantive code changes.
file_pattern...
Analyze only files matching the given file_pattern(s). Can be a list of paths or glob patterns.
DESCRIPTION
The git-fame command provides a summary of contributions by authors in a Git repository, primarily focusing on lines of code (LOC). It analyzes the commit history to determine how many lines each author has added, deleted, or changed. Unlike simple commit counts, git-fame aims to provide a more nuanced view of code ownership and contribution by quantifying the actual lines of code involved. It's often used to get insights into who wrote what, measure team contributions, or identify the primary authors of a project or specific files. The output is typically presented in a tabular format, showing author names, commit counts, and lines of code contributed, with options to sort by various criteria and filter by date or file patterns.
It's important to note that git-fame is not a part of the core Git distribution but is commonly available as a separate script, often through projects like git-extras.
CAVEATS
git-fame is typically a standalone script and not part of the core Git distribution, meaning its availability and exact behavior might vary depending on how it's installed (e.g., via git-extras). Line counting methodologies can also be complex; different tools might yield slightly different LOC counts based on how they handle whitespace, blank lines, renames, and merge commits. The interpretation of 'lines of code' should always consider these nuances.
INSTALLATION
Since git-fame is not a core Git command, it typically needs to be installed separately. The most common way to get it is by installing the git-extras package, which includes git-fame along with many other useful Git utilities. Installation methods vary by operating system (e.g., apt install git-extras on Debian/Ubuntu, brew install git-extras on macOS).
USAGE AND INTERPRETATION
git-fame provides valuable insights into code contributions, but its output should be interpreted carefully. Metrics like 'lines of code' can be misleading without context, as a large number of lines might represent refactoring, boilerplate, or even deletions. It's best used as one metric among many to understand project dynamics, rather than a sole measure of productivity or value.
HISTORY
The git-fame script emerged as a community-contributed tool to address the need for more detailed line-of-code statistics beyond what core Git commands like git shortlog provide. It's not part of the official Git project but has been widely adopted and distributed through various Git utility collections, most notably git-extras, which bundles many useful Git-related scripts. Its development is community-driven, with contributions often focusing on improving line counting accuracy, adding filtering options, and enhancing output formats.
SEE ALSO
git-log(1), git-shortlog(1), git-blame(1), git-diff(1)