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 🙏

© 2025 – Pkg Stats / Ryan Hefner

git-grep-cli

v0.2.0

Published

A simple command line tool to search for commit-message or file-content in a git repository to retrieve the corresponding git hash.

Downloads

765

Readme

git-grep-cli

A simple command line tool to search for commit-message or file-content in a git repository to retrieve the corresponding git hash.

It is more convenient and powerful than the native API provided by git, and can help you find files better (including git's --lost-found objects).

"Regret Medicine" for git

From another point of view, git-grep-cli provides stronger "regret medicine" for git, which can help you quickly find lost files (provided that the lost files have been added to the git staging area; for unreachable objects, it must be the changes within two weeks, because the default value of git gc --prune is two weeks ago).

Example: find a lost file

You can follow these steps to execute it:

# create a file
echo "hello world" > lost-file-1
# add it to the staging area
git add lost-file-1
# undo the staging area
git restore --staged lost-file-1
# delete the file
rm lost-file-1

Now, lost-file-1 is lost, and you want to find it back. You can use git-grep-cli to search for it:

ggc "hello world" -t content

You will get the git-hash of lost-file-1, and then you can use git show <hash> to view the content of this file.

Example: find a lost git-commit record

You can follow these steps to execute it:

# create a file
echo "bye bye" > lost-file-2
# add it to the staging area
git add lost-file-2
# commit it
git commit -m "feat: add lost-git-commit"
# undo the commit
git reset --hard HEAD~1

You can use git-grep-cli to find it back:

# find the lost git-commit record by file content
ggc "bye bye" -t content
# or
# find the lost git-commit record by commit message
ggc "lost-git-commit" -t message

You will get the git-hash of the lost git-commit record, and then you can use git show <hash> to view the content of this commit record. You can also use git cherry-pick <hash> to apply this commit record.

Installing

You need to install git-grep-cli globally.

Package manager

Using npm:

npm install git-grep-cli -g

Using yarn:

yarn add git-grep-cli -g

Using pnpm:

pnpm add git-grep-cli -g

Usage

You can use it in your terminal:

ggc -s <your-search-content> [-t <type>] [-l <length>]

options

  • -s or --search : the search content
  • -t or --type : the search type, message for git commit message, content for file content, all for both
  • -l or --length : the length of the returned content

Example

ggc "hello world"
# or
ggc -s "hello world"
# or
ggc -s "hello world" -t message
# or
ggc -s "hello world" -t content -l 50

Features

  • Support searching for commit-message and file-content
  • Support searching for lost files and lost git-commit records (provided that the lost files have been added to the git staging area)
  • Support specifying the length of the returned content

License

MIT