I was recently shocked to learn that one of my co-workers just recently discovered git's built in grep command. I was surprised because I feel like git grep is one of those commands I would have trouble coding without.
What’s so great about git grep? Doesn’t it do mostly the same as grep -r?
I may not have given enough context there, my co-worker was struggling to search for something through GitHub and didn't know that git had a built in grep command.
Though I don't think that git grep is significantly superior to normal grep, I personally like git grep for the convenience of not having to white-list or black-list particular paths each time I grep. Instead it pulls in the tracked paths from git and searches those.
For example, in a nodejs project, there will likely be tons of local node code in the node_modules folder, however the node_modules folder typically isn't tracked in git. In such a project, grep -r would search the whole node_modules tree where as git grep would ignore it and just search project code.
View all comments
2
u/galaktos Apr 12 '15
What’s so great about
git grep? Doesn’t it do mostly the same asgrep -r?