using linux grep and git ls-files :
$ grep -s "search pattern" $(git ls-files -m)
note 1: Suppress error messages about nonexistent or unreadable files has the grep -s , because git ls-files -m also displays deleted files, due to which grep gives a "No such file or directory" error when a nonexistent file is detected.
note 2: git ls-files' -m option is intended to list only modified files (which also contain deleted files!)
sepehr
source share