Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
git_grep [2018/05/23 12:17] – created rpjdaygit_grep [2018/05/27 13:30] (current) – [Popular options] rpjday
Line 3: Line 3:
 How to use ''git grep'' to search only tracked files, or tracked and new files, etc. How to use ''git grep'' to search only tracked files, or tracked and new files, etc.
  
-Config options:+===== SYNOPSIS =====
  
-  * ''grep.lineNunber''+<code> 
 +$ git grep  
 +  [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp] 
 +  [-v | --invert-match] [-h|-H] [--full-name] 
 +  [-E | --extended-regexp] [-G | --basic-regexp] 
 +  [-P | --perl-regexp] 
 +  [-F | --fixed-strings] [-n | --line-number] 
 +  [-l | --files-with-matches] [-L | --files-without-match] 
 +  [(-O | --open-files-in-pager) [<pager>]] 
 +  [-z | --null] 
 +  [-c | --count] [--all-match] [-q | --quiet] 
 +  [--max-depth <depth>
 +  [--color[=<when>] | --no-color] 
 +  [--break] [--heading] [-p | --show-function] 
 +  [-A <post-context>] [-B <pre-context>] [-C <context>
 +  [-W | --function-context] 
 +  [--threads <num>
 +  [-f <file>] [-e] <pattern> 
 +  [--and|--or|--not|(|)|-e <pattern>...] 
 +  [--recurse-submodules] [--parent-basename <basename>
 +  [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>...] 
 +  [--] [<pathspec>...] 
 +</code> 
 + 
 +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. 
 + 
 +===== Config options ===== 
 + 
 +  * ''grep.lineNumber''
   * ''grep.patternType''   * ''grep.patternType''
   * ''grep.extendedRegexp''   * ''grep.extendedRegexp''
Line 11: Line 39:
   * ''grep.fullName''   * ''grep.fullName''
   * ''grep.fallbackToNoIndex''   * ''grep.fallbackToNoIndex''
 +
 +===== Popular options =====
 +
 +In addition to many standard ''grep'' options:
 +
 +<code>
 +--cached
 +    Instead of searching tracked files in the working tree, search
 +    blobs registered in the index file.
 +
 +--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.
 +</code>
 +
 +===== Examples =====
 +
 +Search a subdirectory:
 +
 +<code>
 +$ git grep -il torvalds -- scripts/
 +scripts/checkstack.pl
 +scripts/get_maintainer.pl
 +scripts/package/mkdebian
 +$
 +</code>
  • git_grep.1527077863.txt.gz
  • Last modified: 2018/05/23 12:17
  • by rpjday