在GIT中查找具有特定单词/行的最新提交 [英] Find the latest commit that had a particular word/line in GIT
本文介绍了在GIT中查找具有特定单词/行的最新提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class A {
String name =玛丽;
$ b $ p $在特定的提交中, String name =Mary ;
已从字符串名称=Bob
更改。事情是,这条线已经被修改了几次(一次是John
,另一次是Adam code>)所以 git blame
没有用。使用Git,除了挖掘日志以外,找出最后一次提交的字符串名称=Bob的最简单方法是什么?
解决方案这是我的
go to command
git log -p -S<搜寻字词>
更多信息
-p
生成修补程序(请参阅生成修补程序一节)。
-S< string>
查找引入或删除< string>实例的差异。
请注意,这与仅出现在diff
输出中的字符串不同;请参阅gitdiffcore(7)中的镐条目了解更多详情。
If I have a file with the latest commit like this:
class A {
String name = "Mary";
}
In a particular commit, String name = "Mary";
was changed from String name = "Bob"
. The thing is, this line has been modified a few times already (at one time it was "John"
, another time was "Adam"
) so git blame
is not useful. With Git, what is the easiest way to find out what was the last commit that had the line String name = "Bob" other than digging through the logs.
解决方案 This is my
go to command
git log -p -S <search term>
More info
-p
Generate patch (see section on generating patches).
-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.
这篇关于在GIT中查找具有特定单词/行的最新提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文