How to search in modified working directory files that have not yet been delivered (indexed)?

It seems that git grep does not have the ability to search only files modified by the working directory before indexing these files. is there any git built-in command for this purpose or should I use git / linux combo commands?

+6
git
source share
2 answers

using linux grep and git ls-files :

 $ grep -s "search pattern" $(git ls-files -m) 

note 1: Suppress error messages about nonexistent or unreadable files has the grep -s , because git ls-files -m also displays deleted files, due to which grep gives a "No such file or directory" error when a nonexistent file is detected.

note 2: git ls-files' -m option is intended to list only modified files (which also contain deleted files!)

+8
source share

git grep modeled on plain grep , maybe you should just use this.

0
source share

All Articles