在某种情况下,我们知道存储库中某个特定的商品提交中使用的关键字。但是我们不知道其中包含什么提交。显然,我可以遍历每个提交的文件并最终找到关键字及其用法,但这将是很多繁琐的工作。
有没有办法在存储库中所有已提交的代码中搜索字符串?
hg grep
确实做到了。
hg grep [OPTION]... PATTERN [FILE]...
search for a pattern in specified files and revisions
Search revisions of files for a regular expression.
This command behaves differently than Unix grep. It only accepts
Python/Perl regexps. It searches repository history, not the working
directory. It always prints the revision number in which a match
appears.
By default, grep only prints output for the first revision of a file
in which it finds a match. To get it to print every revision that
contains a change in match status ("-" for a match that becomes a
non-match, or "+" for a non-match that becomes a match), use the
--all flag.
Returns 0 if a match is found, 1 otherwise.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句