Git & GitHub Interview Question #123

What is git grep?

Advanced GitHub Actions, Repository Internals, Submodules, LFS & Diagnostic Tools Senior Advanced

Quick Interview Answer

git grep searches text in files known to Git and can search the working tree or specified revisions. It is fast and useful for locating symbols, strings, configuration values, or references across a repository.

Detailed Explanation

git grep searches text in files known to Git and can search the working tree or specified revisions. It is fast and useful for locating symbols, strings, configuration values, or references across a repository.

Because it integrates with Git, it can also search committed versions without manually checking them out.

Code Example

git grep "InterviewQuestion"

# Search a specific revision
git grep "InterviewQuestion" HEAD~5