Actually, there is a native Git command for that, git shortlog:
git shortlog -n -s -- myfolder
The options do:
- Option -sjust shows the number of commits per contributor. Without it, the command lists the individual commits per author.
- Option -nsorts the authors by number of commits (descending order) instead of alphabetical.
What is -- good for?
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.