git grep -n 'apiKey' -- '*.js'

Category: Git - Core

git grep -n 'apiKey' -- '*.js'

Search only files matching a path pattern

Restricts the search to paths matching the pattern after the double dash, here JavaScript files only. The -n flag adds line numbers. The pathspec is a glob, so '*.js' hits files in any directory.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.