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.
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>
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.