I'm working with a team on a git project and I would like to see the contribution of each author in terms of lines written or lines edited etc... how can I show statistics for the authors?
5 Answers
As simple as:
git shortlog -s -n
- 1,212
- 1
- 9
- 8
-
7This will count number of commits, not lines of code – a.ch. Nov 18 '20 at 21:37
-
2`-s -n` can be combined together into `-sn` – Mahmoud K. Nov 24 '20 at 17:15
-
29@a.ch. to count the number of lines of code instead, you can use: `git ls-files | while read f; do git blame -w -M -C -C --line-porcelain "$f" | grep -I '^author '; done | sort -f | uniq -ic | sort -n --reverse` – hartmut Dec 03 '20 at 12:08
-
3@hartmut you should post a distinct answer – Vitaly Isaev Mar 05 '21 at 13:04
-
@hartmut this is great, but it doesn't count the lines that are deleted or lines modified by other people – Ching Chang Jul 23 '21 at 18:09
-
@hartmut The command might to have two issues: (1) git submodules (2) spaces in filenames – Martin Thoma Sep 07 '21 at 06:50
-
@MartinThoma I don't think this has an issue with spaces in filenames. – Will Eccles Sep 28 '21 at 20:52
You could try git-stats or use git command to explore from the logs
Refer following posts
- Graphical Stats - Generating statistics from Git repository
- https://gist.github.com/eyecatchup/3fb7ef0c0cbdb72412fc
- Which Git commit stats are easy to pull
- PR-Count Github App - Github ONLY. Thanks @ben
- 1,283
- 11
- 19
-
1You can also try github app: PR Count https://github.com/marketplace/pr-count, if you don't like command line tool. – Ben Mar 28 '20 at 19:43
You should have a look to repoXplorer, an open source project I develop. It is able to compute stats for a project (a group of git repositories) as well as for a contributor and a group of contributors. It provides a REST interface and a web UI. The web UI provides various information like, for a given contributor:
- commits, lines changed and projects count
- date histogram of commits
- top projects by commits
- top projects by lines changed
But best is to have a look to the demo instance here.
Here is a screenshot of the stats page of a contributor (stats are computed accross all repositories indexed by repoxplorer, but can be filtered for a specific project):
- 15,949
- 1
- 17
- 9
-
-
Sure, it can be used with any git repositories. It is not tied to GitHub or other hosting platforms. – Fbo Sep 27 '19 at 21:41
-
are there any instructions for that? I saw only github specific ones at least under "quickstart" – Tim Sep 28 '19 at 11:10
-
1If you use the docker way, then follow the first step of the section https://github.com/morucci/repoxplorer#quickstart---use-the-repoxplorer-docker-container-to-index-a-github-organization in order to start repoXplorer. Then create a "projects.yaml" inside docker-data/conf/ by following https://github.com/morucci/repoxplorer#define-projects-to-index. The github helper is just a tool to read a github organisation from the github API to create a "projects.yaml". In your case you have to create the file manually. – Fbo Sep 29 '19 at 20:51
-
I'd suggest Gitential. It measures:
- coding volume
- coding hours
- productivity
- efficiency
and provides an analytical interface to visualize them on multiple levels:
- projects
- teams
- repos
- developers
It also deduplicates author identities and filter suspicious commits to give a better picture.
- 112
- 3
PR Count is a github app built for showing contribution stats.
You can install for free. No need to write your own scripts or use command line tools.
- 175
- 1
- 2
- 7
-
Hi! Does the "PR Count" app work for private repos too? I installed it but not sure how to see stats. – xke Sep 09 '20 at 23:42
-
Yes, it does work for private repos. Try uninstall and install the app again. It should redirect you to prcount.com where you can see all the stats! @xke – Ben Dec 13 '20 at 23:18
-
Looks like someone may have compromised this app, it redirects to a casino domain on install. – Simon Feb 18 '22 at 17:07