How can I list the author names of a particular folder that's versioned by git?
I see that I can git blame
a file and list the author of each line, but I can't do that for a folder, and I would also like only a unique list (each author listed only once)
The git shortlog command is a special version of git log intended for creating release announcements. It groups each commit by author and displays the first line of each commit message. This is an easy way to see who's been working on what.
Create an empty . gitignore file inside the empty folder that you would like to commit. Git will only track Files and the changes in them. So folders are tracked as part of the file changes in them.
Actually, there is a native Git command for that, git shortlog
:
git shortlog -n -s -- myfolder
will give a list of contributors that created commits that touched myfolder
. Option -s
means summary and just shows the number of commits per contributor. Without it, the command lists the commit message summaries (1st line) per author. Option -n
sorts the authors by number of commits (from most to least) instead of alphabetical.
And just in case you have not encountered a loose --
in a git command yet: it is a separator option to mark that what follows cannot be a <revspec>
(range of commits), but only a <pathspec>
(file and folder names). That means: if you would omit the --
and by accident had a branch or tag named myfolder, the command git shortlog -n -s myfolder
would not filter for the directory myfolder, but instead filter for history of branch or tag "myfolder". This separator is therefore useful (and necessary) in a number of git commands, like log
or checkout
, whenever you want to be clear whether what you specify is either a revision (commmit, branch, tag) or a path (folder or file name). And of course, this site already has a question on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With