1

如何在git项目中搜索任何函数或变量的作者?当我找到一些函数或变量时,我很好奇,我想知道是谁创造了这些东西。有什么方法可以追踪作者姓名和创作时间吗?

4

2 回答 2

2

git blame将确定谁最后修改了文件/修订版中的每一行

于 2012-08-08T09:14:54.833 回答
2

根据布赖恩的回答,git blame将告诉您最近的提交者/提交以修改一行,但是如果您想一直跟踪该行,则需要“镐搜索”:

-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.

假设您想methodFoo在 file中查找字符串的全部历史记录TroublingClass。您可以使用git log如下命令:

git log -S"methodFoo" -- TroublingClass

旗帜-S只是没有得到应有的关注。在归因故障或调查错误历史时,它非常有用。

于 2012-08-08T12:33:36.750 回答