I am trying to search for a string (e.g. search for string "TODO") in all of my files which are changed locally. That includes files which were already staged and those that are changed but are not added to staging area yet.
simply typing git status gives you a list of staged files, a list of modified yet unstaged files, and a list of untracked files.
This intermediate area, the staging area or index or cache, contains the proposed next commit. You start out by checking out some commit. At this point, you have three copies of every file: One is in the current commit (which Git can always find by the name HEAD ).
Answering my own question. I was able to do it with the following command
git diff --name-only | xargs grep 'My search string goes here'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With