我可以让git告诉我一个用户修改过的所有文件吗?


147

我想git给我一个清单,列出所有提交中一个用户修改的所有文件。

我的特殊用例是我参与了ruby on rails项目的i18n,我们想知道已经完成了哪些文件,还需要完成哪些文件。有问题的用户仅在i18n上完成过工作,而在其余代码库上没有完成过工作。因此信息应该全部在git中,但是我不确定如何将其发布。

Answers:


127

这不是唯一的方法,但是可以起作用:

git log --pretty="%H" --author="authorname" |
    while read commit_hash
    do
        git show --oneline --name-only $commit_hash | tail -n+2
    done | sort | uniq

或者,作为一行:

git log --pretty="%H" --author="authorname" | while read commit_hash; do git show --oneline --name-only $commit_hash | tail -n+2; done | sort | uniq

184

这将为您提供一个简单的文件列表,仅此而已:

git log --no-merges --author="Pattern" --name-only --pretty=format:"" | sort -u

根据需要将--author切换为--committer。


1
--name-only似乎使输出仅是文件名。鉴于这一事实,有哪些选择--stat--pretty=format:""成就?你能把他们排除在外吗?
乔纳2015年

1
@Jonah --pretty = format:“”是必需的。我编辑了答案。
伊恩·凯林

2
伟大工程,但一个很小的故障:它产生在输出的开始空白的链接,这意味着通过管道“WC -l”结果由1获得文件的计数是关闭
约阿希姆

如何排除已删除的文件?
蒂姆·博兰德

8

尝试git log --stat --committer=<user>。只需将用户名放在--committer=选项上(或使用--author=适当)。

这将使每次提交吐出所有文件,因此可能会有一些重复。


0
git log --pretty= --author=@abcd.com --name-only | sort -u | wc -l

在git repo中显示公司所有修改过的文件。

git log --pretty= --author=user@abcd.com --name-only | sort -u | wc -l

在git repo中按作者名称“ user”显示所有修改的文件。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.