Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make git-grep ignore large text files

Tags:

git

grep

How do I make git grep ignore large text files? Though I have some thousands of them, I never need to grep over them. (Think of foreign-language dictionary.) Hence, every time I do git grep I have to specify a path explicitly or cd there, because else it would take ages:

$ time git grep something somewhere/
somewhere/file.txt: something
real    0m0.049s
user    0m0.044s
sys     0m0.040s

If I could make git grep ignore said files, I would do it with less typing:

$ time git grep something
somewhere/file.txt: something
real    1m22.159s
user    0m0.472s
sys     0m1.448s

This used to be the case, but now the times are appalling. Also, I can't remove these files from git, because I need to track changes in them. Hence, adding them to .gitignore doesn't help.

like image 306
sanmai Avatar asked Aug 05 '26 16:08

sanmai


1 Answers

I would be inclined to re-organize my project so that the large text files that are 'data' are in a different folder from where I typically grep. Does not take much effort to do and keeps the non-source code components out of the way of the day to day operations.

like image 50
miltonb Avatar answered Aug 08 '26 11:08

miltonb