makeHumansTxt
A script to generate a humans.txt file listing all contributors to a Git project, with multiple ways to measure contributions.
Overview
This script analyzes a Git repository to identify all contributors and generates a humans.txt file - a standard way to credit the people behind a website or project. Contributors can be ranked by different metrics: commit count, total lines added/changed, or lines currently remaining in the codebase.
Usage
# Basic usage (counts by commits)
makeHumansTxt
# Count by different metrics
makeHumansTxt --commits # Count by number of commits (default)
makeHumansTxt --lines-added # Count by total lines added/changed
makeHumansTxt --lines-current # Count by lines currently in codebase
# Show actual counts next to names
makeHumansTxt --show-counts
makeHumansTxt --lines-current --show-counts
# Get help
makeHumansTxt --helpThe script outputs the humans.txt content to standard output. To save it to a file:
makeHumansTxt --lines-current > humans.txtOptions
--commits: Count by number of commits (default behavior)--lines-added: Count by total lines added/changed across all commits--lines-current: Count by lines currently remaining in the codebase (using git blame)--show-counts: Display the actual counts next to contributor names--help,-h: Show help message
Output Format
The generated file follows this format:
Made by the following team:
* Most Active Contributor
* Second Most Active Contributor
* Third Most Active Contributor
* ...With --show-counts, the format includes metrics:
Made by the following team:
* Alice Johnson (127 commits)
* Bob Smith (89 lines currently in codebase)
* Charlie Brown (1,234 lines added/changed)
* ...How Each Method Works
--commits (Default)
- Analyzes all commits in the current Git repository
- Extracts author names from commit messages
- Counts commits per author
- Sorts by commit count (descending)
--lines-added
- Uses
git log --numstatto get line changes for each commit - Sums added and deleted lines for each author across all commits
- Provides a measure of total code contribution volume
- Sorts by total lines changed (descending)
--lines-current
- Uses
git blameon all text files in the repository - Counts how many lines each author has in the current codebase
- Shows current ownership/responsibility for the code
- Excludes binary files automatically
- Sorts by current line count (descending)
Use Cases
- Website credits: Add a
humans.txtfile to your website's root directory - Project documentation: Include contributor credits in project documentation
- Team recognition: Generate a list of team members sorted by contribution
- Annual reports: Create contributor summaries for yearly reviews
Examples
# Generate and save humans.txt
makeHumansTxt > humans.txt
# Preview the output
makeHumansTxt
# Generate for a specific directory
cd /path/to/project && makeHumansTxt > humans.txt
# Combine with other information
echo "/* Our amazing team */" > humans.txt
makeHumansTxt >> humans.txt
echo "/* Visit https://example.com */" >> humans.txtRequirements
- Git repository with commit history
- Standard Unix utilities (awk, sort)
About humans.txt
The humans.txt file is a web standard (http://humanstxt.org/) that provides a way to credit the people behind a website. It's typically placed in the root directory of a website and can be referenced in HTML with:
<link type="text/plain" rel="author" href="humans.txt" />Notes
- The script considers all commits in the repository history
- Author names are extracted exactly as they appear in Git commits
- Contributors with different email addresses but same names are treated as separate entries
- The output includes asterisks (*) as bullet points for each contributor
- Empty lines are included for proper formatting