我想在git的文件历史中找到一个字符串,我知道要在所有文件中找到它是这样的:
git grep whatever $(git rev-list --all)
但是我想在文件的历史记录中找到它,例如我想知道如何在文件中找到字符串'preg_match':datacar.php
答案 0 :(得分:2)
可以使用 the pickaxe
git log -S preg_match -- datacar.php
如果你想要差异
git log -p -S preg_match -- datacar.php
更多信息
-S<string> Look for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output; see the pickaxe entry in gitdiffcore(7) for more details.