Created
March 28, 2022 21:53
-
-
Save beveradb/1c7b00bb1459d51389a574307df944a0 to your computer and use it in GitHub Desktop.
Grep the git history for a batch of repos in bulk, to see if a string has ever been referenced in any of the repos
This file contains 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 | |
# Usage: gitsearch.sh stringToSearchFor * | |
# | |
# If you have a lot of repos to search, you might want to run this in a tmux session and pipe the results into a logfile with tee, e.g. | |
# | |
# cd folderWithLotsOfReposInIt | |
# gitsearch.sh stringToSearchFor * | tee /tmp/gitsearch-stringToSearchFor.log | |
# | |
expression=$1 | |
shift | |
echo ${expression} | |
for repo in "$@" | |
do | |
if [ -d ${repo} ] | |
then | |
echo "Searching ${repo}" | |
cd ${repo} | |
git rev-list --all | xargs git --no-pager grep "${expression}" | |
cd - > /dev/null | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment