有一个包含大量提交的 repo 协议(protocol)。我知道我正在寻找的文件的名称和东西(一个字符串,准确地说是一些系数),但我不知道它在什么提交中。它不再是当前的一个,这是肯定的,前面几个也没有。
*我如何按时间搜索指定文件(或整个存储库中,我不不在乎),所以它会遍历所有提交直到他找到它?*
对 mercurial 和 git 都感兴趣。目前两者都在使用,我真的不知道这是否适用于其中任何一个。
最佳答案
Mercurial 有 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.
对于 Git,这个相关问题似乎很相关:
关于git - 如何搜索 repo 历史?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8099680/