Measuring Project ‘Health’ with git-quick-stats: In-depth Git Statistics Directly on Your Terminal

Git tutorial - IT technology blog
Git tutorial - IT technology blog

Why do you need more than just a git log command?

Have you ever wondered how “healthy” your project actually is? Often, we judge productivity based on gut feelings like “the team seems to be working hard lately.” But to provide a convincing report to your boss or simply optimize your workflow, you need numbers that speak for themselves.

In the past, I used to run <a href="https://itfromzero.com/en/git-en/advanced-git-log-filter-commits-by-author-time-and-file-visualize-branches-with-graph-pretty.html">git log</a> --author="Name" --oneline | wc -l to count commits. This approach was too primitive. It didn’t show the big picture of code additions, deletions, or contribution frequency by time of day. Once, a new member accidentally force-pushed to the wrong branch, wiping out the team’s code in a single afternoon. If I had been monitoring the repo history closely, things might have been different. Since then, I started looking for more visual analysis tools.

git-quick-stats is a lightweight command-line interface (CLI) tool that doesn’t require setting up complex dashboards like Grafana. It helps you examine every metric of a Git repository in just a few seconds.

Installing git-quick-stats in a flash

This tool is essentially an optimized shell script. Depending on your operating system, you can install it quickly using the following methods:

1. For macOS

If you have Homebrew installed, just type:

brew install git-quick-stats

2. For Linux (Ubuntu/Debian)

For Debian-based distributions, use the apt command:

sudo apt update && sudo apt install git-quick-stats

Arch Linux users can find it in the AUR:

yay -S git-quick-stats

3. Installing from Source

If you want the latest version, clone it directly from GitHub:

git clone https://github.com/arzzen/git-quick-stats.git
cd git-quick-stats
sudo make install

After installation, type git-quick-stats -v to confirm everything is ready.

Leveraging Data: From Interaction to Automation

The biggest advantage of git-quick-stats is its support for both an intuitive interactive menu and flexible command-line flags.

Interactive Menu Mode

Simply navigate to your project directory and run the command without any parameters:

git-quick-stats

A menu with over 20 options will appear. You can easily check:

  • Author stats: Who contributes the most?
  • Daily stats: Which day of the week is the team most productive?
  • Language stats: The distribution of programming languages in the project.

Command-Line Mode (For Automation)

If you need to fetch data quickly to send to Slack or save to a log file, use direct flags. These are the commands I use frequently:

View an overview of all members’ contributions:

git-quick-stats -a

Filter data by time (e.g., for Sprint Reviews):
Use the _GIT_SINCE environment variable to limit the statistical range.

export _GIT_SINCE="2024-01-01"
git-quick-stats -u

A small tip: Don’t just look at the number of commits. Pay attention to the ratio of insertions and deletions. A good developer often deletes more redundant code than they write new code.

Turning Data into Action

Data is only valuable when you know how to interpret it. Here are three ways I use this tool to improve project quality:

1. Hunting for Risky “Hotspots”

Use the git-quick-stats -f command to list the most frequently modified files. If UserService.java has 500 changes while other files have fewer than 50, it’s a sign of Tight Coupling. This file might be carrying too much logic and needs immediate refactoring.

2. Identifying Burnout Risks

The git-quick-stats -T command displays a contribution graph by hour. If the graph shows a high density of commits at 1-2 AM, your team might be overloaded. As a leader, I would adjust the workload instead of just praising that “hard work.”

3. Cleaning up “Junk” in the Repo

I once discovered an old module that hadn’t been touched for two years thanks to the file statistics feature. After boldly deleting it, the source code size decreased by 15%, significantly speeding up CI/CD build times. This also makes git fetch lighter for everyone.

In summary, git-quick-stats is not a tool for “spying” on employees. It is a medical stethoscope that helps you understand the health of your project. Use it to improve workflows rather than putting pressure on your teammates.

Share: