git grep通过文件扩展名 [英] git grep by file extensions

查看:125
本文介绍了git grep通过文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,如果我只想在某些扩展名的文件上grep一个模式,我可以这样做:

I know that, if I wanted to grep for a pattern only on files with certain extensions, I could do this:

// searches recursively and matches case insensitively in only javascript files
// for "res" from the current directory
grep -iIr --include=*.js res ./

我一直在尝试通过git grep来寻找一种方法来做到这一点(利用git grep的速度它用树存储的索引),但无济于事。我在这里看到排除某些文件类型是不可能的。

I've been trying to search for a way to do this via git grep as well (to take advantage of git grep's speed from the indexes it stores with its tree), but to no avail. I saw here that excluding certain file types is not possible.

推荐答案

是的,例如:

Yes, for example:

git grep res -- '*.js'

这篇关于git grep通过文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆