how to find recent committers of a file in git?
Is there a way 开发者_如何转开发to find who recently changed a file in git?
For exaxmple, I need last 5 people who changed this file. I tried git annotate
and git blame
but I could not find the exact thing I wanted.
git shortlog does what you want:
git shortlog -sne <filename>
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. If you just want the last 5 commits then git log
alone can be used:
$ git log -5 <filepath>
Try:
git log filename
You can play around with the log output (see man git-log) to get just the info you want.
I found this useful to display the last 5 authors of a single file
git log -n 5 --pretty='format:%an' -- path/to/file
-n <number>
- number of commits (in this case authors) to be displayed
--pretty='format:%an'
- display only the author name
I'm using
gitk filename
Thorsten
精彩评论