Git 命令获取包含特定文本的文件的所有提交者列表

Git command to get list of all committers to files containing specific text

What git 命令获取包含特定文本的文件的所有提交者的列表。这可以选择包括一个 before/after 参数。我面临的问题是,是否有针对此的任何特定命令,或者我可以获取文件列表并将其通过管道传递给某个命令吗?

可能类似于

git log --all -S "the string you search for" --pretty='%cn%n'

详情:

-S 使用以下参数

中给定的字符串过滤提交

%cn 打印提交者姓名

%n只是换行

尝试使用此命令 git 包含特定文本的文件的所有提交者姓名和电子邮件:

    git log -S "search string" --stat --pretty=format:"%cn -%ce (%cd)"

分两个阶段进行。首先让我们获取文件列表:

files=`git grep -l "searh string"`

有了这个列表,让我们列出所有涉及文件的提交,为每个提交获取作者的 name/email,对作者列表进行排序,只打印唯一的 name/email。

git log --format='%an <%ae>' -- $files | sort -u

将两个命令合二为一:

git log --all --format='%an <%ae>' -- `git grep -l "search string"` | sort -u