Last active
July 6, 2025 19:13
-
-
Save airvzxf/bb782126c61c8293ed6b463005d11330 to your computer and use it in GitHub Desktop.
Search text in all the objects in a Git repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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