You can use the shell script to iterate over all the files that are currently being tracked using Git, and then determine if each file contains a line:
for f in $(git ls-files); do commits=$(git log -S'string' --oneline -- $f | wc -l) if [[ $commits -gt 0 ]]; then echo $f fi done
This list will not list the files that contained this line, but were subsequently deleted.
source share