[英]how to find recent committers of a file in git?
Is there a way to find who recently changed a file in git?有没有办法找到谁最近在 git 中更改了文件?
For exaxmple, I need last 5 people who changed this file.例如,我需要最后 5 个更改此文件的人。 I tried git annotate
and git blame
but I could not find the exact thing I wanted.我尝试了git annotate
和git blame
但我找不到我想要的确切内容。
Probably not the most efficient or sensible way, but this seems to work:可能不是最有效或最明智的方式,但这似乎有效:
$ git log <filepath> | grep Author: | cut -d' ' -f2- | uniq | head -n5
This is assuming you actually want the last 5 authors , irrespective of how many commits each of them might have made.这是假设您实际上想要最后 5 个author ,而不管他们每个人可能进行了多少次提交。 If you just want the last 5 commits then git log
alone can be used:如果您只想要最后 5 次提交,则可以单独使用git log
:
$ git log -5 <filepath>
git shortlog 做你想要的:
git shortlog -sne <filename>
Try:尝试:
git log filename
You can play around with the log output (see man git-log) to get just the info you want.您可以使用日志输出(参见 man git-log)来获取您想要的信息。
I found this useful to display the last 5 authors of a single file我发现这对于显示单个文件的最后 5 个作者很有用
git log -n 5 --pretty='format:%an' -- path/to/file
-n <number>
- number of commits (in this case authors) to be displayed -n <number>
- 要显示的提交数(在本例中为作者)
--pretty='format:%an'
- display only the author name --pretty='format:%an'
- 只显示作者姓名
I'm using我在用着
gitk filename
Thorsten托尔斯滕
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.