git search | grep and ls-files
Git | How do I Search For Strings, Files and Folders
These commands search the entire project in your working copy – that’s the simple way – but you can get funky and search all manner of corners using certain modifiers.
It doesn’t matter at which directory level you are – unlike the Linux grep command that searches the folder you are in (or recursively below with a -r switch).
git ls-files *.html» to find all html files
git grep simple» to search (project) for lines containing “simple”
git grep -in simple» case insensitive search for “simple” (with line numbers printed)
git grep simple -- *.html» search for “simple” in html files
git grep -in "simple " -- *.java» simple followed by space in java files
get funky and search all manner of corners
You can search files that have been deleted, ignored, staged, not yet merged and even modified using switches like below.
Git can be over-complicated so here are “simple as” listings command groups that deliver observable value.
Just because you can (handle complexity) does not mean you should.
You want your brain working on your domain – not fighting with abstract version control concepts. These 7 things are what you’ll do with Git 90% of the time.