简体   繁体   English

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

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

What git command gets the list of all committers to files containing specific text. 什么git命令获取包含特定文本的文件的所有提交者的列表。 This can optionally include a before/after parameter. 这可以可选地包括前/后参数。 The problem I am facing is, is there any specific command for this, or can I get the list of files and pipe it to some command? 我面临的问题是,是否有任何特定的命令,或者我可以获取文件列表并将其传递给某些命令?

probably something along the lines of 可能是一些东西

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

Details : 细节 :

-S filters commits using the string given in following parameter -S过滤器使用以下参数中给出的字符串进行提交

%cn prints the committer name %cn打印提交者名称

%n is just a new line %n只是一个新行

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

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

Let do that in two stages. 让我们分两个阶段。 1st let's get the list of files: 第一个让我们得到文件列表:

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

Having the list let's list all commits that touch the files, get the author's name/email for every commit, sort the list of authors printing only unique name/email. 让列表让我们列出所有触摸文件的提交,获取每次提交的作者姓名/电子邮件,对作者列表进行排序,只打印唯一的名称/电子邮件。

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

Combine two commands into one: 将两个命令合并为一个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM