【发布时间】:2016-11-17 15:43:16
【问题描述】:
所以我想在我的项目中找到 NLog 的使用,我使用 git grep 为我这样做,但它发现了比我需要的更多的案例:
git grep NLog
GETA.Seo.Sitemap/Geta.SEO.Sitemaps.csproj: <Reference Include="NLog, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
GETA.Seo.Sitemap/Geta.SEO.Sitemaps.csproj: <HintPath>..\packages\NLog.2.1.0\lib\net45\NLog.dll</HintPath>
GETA.Seo.Sitemap/Services/CloudinaryService.cs: NLogger.Exception("Could not transform image", exception);
GETA.Seo.Sitemap/Services/CloudinaryService.cs: NLogger.Warn("Url for cloudinary id was null");
GETA.Seo.Sitemap/Services/CloudinaryService.cs: NLogger.Warn("Could not locate file object for cloudinary id in EpiServer");
....
etc
当然,它找到了我要查找的内容,但我想过滤到仅以 .cs 结尾的文件。所以我尝试这样做:
git grep NLog **/*.cs
Web/Global.asax.cs: NLogger.Info("Meny application start");
只有一击,我上面的两场比赛都没有列出。我发现这很奇怪,我可能误解了 git grep 的 globbing 匹配。有人可以启发我吗?
【问题讨论】:
-
git grep '*.cs'是否按预期工作? -
尝试
git grep '**/*.cs'(单引号或双引号),假设您使用的是各种标准外壳中的任何一种。可能您的外壳将**/*.cs扩展为Web/Global.asax.cs或类似的。请注意,只有 一些 shell 模拟 Git 的**。 (当然,如果您也愿意在顶级目录中查找文件,只需git grep '*.cs'即可。) -
@torek 就是这样。显然,这对我来说太晚了。请添加您的评论作为答案,我会给您答案。