我可以让 git 告诉我一个用户修改过的所有文件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6349139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I get git to tell me all the files one user has modified?
提问by Hamish Downer
I would like git to give me a list of all the files modified by one user, across all commits.
我希望 git 给我一份由一个用户修改的所有文件的列表,涵盖所有提交。
My particular use case is that I've been involved in the i18n of a ruby on rails project, and we want to know what files have already been done and what files still need to be done. The users in question have only done work on the i18n, not on the rest of the code base. So the information should all be in git, but I'm not sure how to get it out.
我的特殊用例是我参与了一个 ruby on rails 项目的 i18n,我们想知道哪些文件已经完成,哪些文件还需要完成。有问题的用户只在 i18n 上完成了工作,而不是在其余的代码库上。所以信息应该都在git中,但我不知道如何把它弄出来。
采纳答案by Steve Prentice
This isn't the only way, but it works:
这不是唯一的方法,但它有效:
git log --pretty="%H" --author="authorname" |
while read commit_hash
do
git show --oneline --name-only $commit_hash | tail -n+2
done | sort | uniq
Or, as one line:
或者,作为一行:
git log --pretty="%H" --author="authorname" | while read commit_hash; do git show --oneline --name-only $commit_hash | tail -n+2; done | sort | uniq
回答by h0tw1r3
This will give you a simple list of files, nothing else:
这将为您提供一个简单的文件列表,仅此而已:
git log --no-merges --author="Pattern" --name-only --pretty=format:"" | sort -u
Switch --author for --committer as necessary.
根据需要将 --author 切换为 --committer。
回答by Robert S.
Try git log --stat --committer=<user>
. Just put the user's name on the --committer=
option (or use --author=
as appropriate).
试试git log --stat --committer=<user>
。只需将用户名放在--committer=
选项上(或--author=
根据需要使用)。
This will spit out all the files per commit, so there will likely be some duplication.
这将吐出每次提交的所有文件,因此可能会有一些重复。
回答by Abhijeet Kandalkar
git log --pretty= [email protected] --name-only | sort -u | wc -l
Shows all modified files by company in the git repo.
在 git repo 中按公司显示所有修改过的文件。
git log --pretty= [email protected] --name-only | sort -u | wc -l
Shows all modified files by author name 'user' in the git repo.
在 git repo 中按作者姓名“user”显示所有修改过的文件。