如果我有一个包含最新提交的文件,请执行以下操作:
class A {
String name = "Mary";
}
在特定提交中,String name = "Mary";
已从String name = "Bob"
更改。问题是,这一行已经被修改了几次(一次是"John"
,另一次是"Adam"
)所以git blame
没用。使用Git,最简单的方法是找出除了挖掘日志之外的最后一次提交行字符串名称=“Bob”的内容。
答案 0 :(得分:4)
这是我的 go to command
git log -p -S <search term>
更多信息
-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.