Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search for a string in all of the files in git's staging area and all those files changed but not staged

Tags:

git

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.

like image 298
user462455 Avatar asked Apr 09 '14 18:04

user462455


People also ask

How do I list files in my staging area?

simply typing git status gives you a list of staged files, a list of modified yet unstaged files, and a list of untracked files.

What is the staging area or index in git Select all matching options?

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 ).


1 Answers

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'
like image 101
user462455 Avatar answered Sep 20 '22 18:09

user462455