git-grep
Search patterns in tracked files
TLDR
Search for pattern
SYNOPSIS
git grep [options] pattern [revision] [--] [path]
DESCRIPTION
git grep searches tracked files for patterns, optimized specifically for Git repositories. Unlike regular grep, it ignores untracked files and can search any commit in the repository history.
The command is significantly faster on large repositories because it uses Git's index rather than scanning the filesystem directly. It supports the same regex syntax as grep and integrates seamlessly with Git's revision and path specifications.
PARAMETERS
PATTERN
Search pattern (regex).REVISION
Commit/branch to search.-n, --line-number
Show line numbers.-i, --ignore-case
Case insensitive.-l, --files-with-matches
Show only filenames.-c, --count
Show match counts.-w, --word-regexp
Match whole words.-e PATTERN
Pattern argument.--help
Display help information.
CAVEATS
Only searches tracked files. Regex syntax differs from grep. Binary files skipped by default.
HISTORY
git grep is a core Git command providing optimized search that understands git's object model and history.
