Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to git grep for tabs?

Tags:

git

grep

This question specifies that -P allows GNU grep to grep for a tab

grep -P '\t' config/file.txt 

However, using git grep, I can't work out how to grep for a tab:

git grep '\t' # Looks for files with the letter "t" instead git grep -P '\t' # Invalid option git grep -E '\t' # Does the same as without the -E 

And there doesn't seem to be an option for substituting in your own grep program. Is my only option to slurp the entire contents and then use GNU grep on the results?

like image 623
Andrew Grimm Avatar asked Nov 23 '10 23:11

Andrew Grimm


People also ask

How do you grep for a tab?

just use grep "<Ctrl+V><TAB>" , it works (if first time: type grep " then press Ctrl+V key combo, then press TAB key, then type " and hit enter, voilà!)

What files can be searched using git grep '?

Git ships with a command called grep that allows you to easily search through any committed tree, the working directory, or even the index for a string or regular expression. For the examples that follow, we'll search through the source code for Git itself.

How does git grep work?

`git grep` command is used to search in the checkout branch and local files. But if the user is searching the content in one branch, but the content is stored in another branch of the repository, then he/she will not get the searching output.


1 Answers

You can work around this by typing a literal tab into your command:

# type it with ^V then tab git grep '  ' 
like image 136
Cascabel Avatar answered Oct 03 '22 10:10

Cascabel