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.
假设我有一个bar.cpp已提交到 git 的文件。在过去的某个时候,我曾经foo在那个文件中有一个。
bar.cpp
foo
问题
如何找到bar.cpp包含该字符串的所有 git 修订版foo?
笔记
命令行解决方案会很棒。
可以使用 镐
git log -S foo bar.cpp
如果你想要差异
git log -p -S foo bar.cpp
更多信息
-S<字符串> 寻找引入或删除实例的差异 <字符串>。请注意,这与字符串不同 出现在差异输出中;查看 gitdiffcore(7) 中的镐条目 更多细节。