Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - list all authors of a folder of files?

Tags:

git

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)

like image 632
JuJoDi Avatar asked Jul 17 '14 15:07

JuJoDi


People also ask

What is git Shortlog?

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.

How do I track a folder in git?

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.


Video Answer


1 Answers

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.

like image 52
ojdo Avatar answered Sep 19 '22 17:09

ojdo