Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我试图在基于 git 的项目中查找模式时,我输入:
git grep <pattern>
并且 git 在整个项目中搜索该模式。有时这会在非源文件中找到匹配项,这使得查找我正在寻找的内容变得更加困难。
我如何告诉它只搜索 Python (.py) 或其他一些源文件?
您可以使用 :
git grep <pattern> -- '*.<ext>'
在哪里 :
pattern
ext
<ext>
git grep HelloWorld -- '*.json'