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?
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à!)
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.
`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.
You can work around this by typing a literal tab into your command:
# type it with ^V then tab git grep ' '
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