This is an old revision of the document!


How to use git grep to search only tracked files, or tracked and new files, etc.

Config options:

  • grep.lineNumber
  • grep.patternType
  • grep.extendedRegexp
  • grep.threads
  • grep.fullName
  • grep.fallbackToNoIndex

NOTE: If you don't specify a <pathspec> to search, it (apparently) defaults to the current working directory – this is not obvious from the man page.

--cached
    Instead of searching tracked files in the working tree, search
    blobs registered in the index file.

--no-index
    Search files in the current directory that is not managed by Git.

--untracked
    In addition to searching in the tracked files in the working
    tree, search also in untracked files.

--no-exclude-standard
    Also search in ignored files by not honoring the .gitignore
    mechanism. Only useful with --untracked.

--exclude-standard
    Do not pay attention to ignored files specified via the
    .gitignore mechanism. Only useful when searching files in the
    current directory with --no-index.

Search a subdirectory:

$ git grep -il torvalds -- scripts/
scripts/checkstack.pl
scripts/get_maintainer.pl
scripts/package/mkdebian
$
  • git_grep.1527105412.txt.gz
  • Last modified: 2018/05/23 19:56
  • by rpjday