Skip to content

Instantly share code, notes, and snippets.

@airvzxf
Last active July 6, 2025 19:13
Show Gist options
  • Save airvzxf/bb782126c61c8293ed6b463005d11330 to your computer and use it in GitHub Desktop.
Save airvzxf/bb782126c61c8293ed6b463005d11330 to your computer and use it in GitHub Desktop.
Search text in all the objects in a Git repository
#!/bin/bash
set -e
set +xv
# Use an environment variable for the text that you are looking for.
# SEARCH_STRING="PUT_YOUR_TEXT" ./git-grep-all.bash
# Or, set the text hardcoded in this script.
if [ -z "${SEARCH_STRING}" ]; then
# Define the text you are looking for.
SEARCH_STRING="PUT_YOUR_TEXT"
fi
echo "Searching the word: '${SEARCH_STRING}'…"
git grep --text --ignore-case --line-number --recursive --color=always --threads=4 "${SEARCH_STRING}" $(git rev-list --all --objects | cut -d ' ' -f 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment