npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

difflog

v26.6.4

Published

Find a commit by fuzzy-searching git log and printing its diff.

Readme

difflog

Find a commit by fuzzy-searching git log and print its diff.

difflog is a small CLI helper for quickly finding a commit by message or hash and outputting the diff for that commit.

Usage

npx difflog [options] -- <search terms>

Example:

npx difflog -e package-lock.json -o diff.txt -u 999999 -- JIRA-123 mobile

This searches the Git history for a commit similar to:

JIRA-123 mobile

Then outputs the diff for the matched commit, excluding package-lock.json, using 999999 unified context lines, and saving the result to diff.txt.

Options

-b, --body                Include commit body in fuzzy search
-e, --exclude <path...>   Exclude one or more paths from the diff
-o, --output <file>       Write diff output to a file
-s, --stat                Output diff stat instead of the full patch
-u, --unified <lines>     Number of unified diff context lines

CLI messages (errors, the saved confirmation, ambiguous lists, and hints) are lightly colored for readability. The actual diff or stat is always raw Git output with no coloring, so it stays safe to pipe or redirect.

Output size in bytes is reported only when writing to a file with -o. When the diff or stat goes to stdout, nothing extra is printed before or after it.

Examples

Print a commit diff to stdout:

npx difflog -- JIRA-123 mobile

Save a commit diff to a file:

npx difflog -o diff.txt -- JIRA-123 mobile
# Saved diff for abc1234 -> JIRA-123 Fix mobile view to diff.txt (123456 bytes)

Show a diff stat instead of the full patch:

npx difflog -s -- JIRA-123 mobile

Save a diff stat to a file:

npx difflog -s -o stat.txt -- JIRA-123 mobile
# Saved stat for abc1234 -> JIRA-123 Fix mobile view to stat.txt (1234 bytes)

Combine excludes with a stat:

npx difflog -s -e package-lock.json -- JIRA-123 mobile

Include the commit body in the fuzzy search (matching beyond the subject):

npx difflog -b -- "rollback plan"

Exclude one file:

npx difflog -e package-lock.json -- JIRA-123 mobile

Exclude multiple files:

npx difflog -e package-lock.json yarn.lock pnpm-lock.yaml -- JIRA-123 mobile

Repeat -e:

npx difflog -e package-lock.json -e yarn.lock -- JIRA-123 mobile

Use a large unified context:

npx difflog -u 999999 -- JIRA-123 mobile

Search by short hash:

npx difflog -- abc1234

Search by full hash:

npx difflog -- abc1234567890abcdef1234567890abcdef12345678

Important: use -- before search terms

When using options, especially --exclude, pass search terms after --:

npx difflog -e package-lock.json -- JIRA-123 mobile

This prevents search terms from being interpreted as option values.

Matching behavior

difflog searches commit history using:

  • full commit hash
  • short commit hash
  • commit subject

With -b, --body, the commit body is also included in the search. -b only affects matching; it does not change the diff or stat output, and ambiguous match lists still show only the short hash and subject.

If there is one clear best match, it prints or saves that commit’s diff.

If multiple commits match similarly, difflog does not guess. It prints a ranked list and asks you to refine the search.

Example:

Multiple commits matched "mobile". Refine your search:
  1. abc1234  JIRA-123 Fix mobile view for tenant clients page
  2. def5678  JIRA-124 Improve mobile spacing in assessment form

Diff behavior

For normal commits, difflog outputs the equivalent of:

git diff <commit>^!

That means the output is a plain diff for the selected commit, without the commit header or commit message metadata included by git show.

For root commits, difflog compares the root commit against the repository’s empty tree, so the output shows what the first commit introduced.

Merge commits

Merge commits are not diffed automatically.

A merge commit can be interpreted in multiple ways, so difflog stops with a clear message instead of producing misleading output.

For merge commits, inspect the commit manually with Git:

git show <commit>
git show --first-parent <commit>

Requirements

  • Node.js >= 20
  • Git
  • Run from inside a Git repository

License

ISC