Is there a command I can invoke which will count the lines changed by a specific author in a Git repository? I know that there must be ways to count the number of commits as Github does this for their Impact graph.
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Compile and build with single command line Java (L
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
Here's a short one-liner that produces stats for all authors. It's much faster than Dan's solution above at https://stackoverflow.com/a/20414465/1102119 (mine has time complexity O(N) instead of O(NM) where N is the number of commits, and M the number of authors).
To count number of commits by a given author (or all authors) on a given branch you can use git-shortlog; see especially its
--numbered
and--summary
options, e.g. when run on git repository:you can use whodid (https://www.npmjs.com/package/whodid)
and
or just type
then you can see result like this
This script here will do it. Put it into authorship.sh, chmod +x it, and you're all set.
The output of the following command should be reasonably easy to send to script to add up the totals:
This gives stats for all commits on the current HEAD. If you want to add up stats in other branches you will have to supply them as arguments to
git log
.For passing to a script, removing even the "oneline" format can be done with an empty log format, and as commented by Jakub Narębski,
--numstat
is another alternative. It generates per-file rather than per-line statistics but is even easier to parse.After looking at Alex's and Gerty3000's answer, I have tried to shorten the one-liner:
Basically, using git log numstat and not keeping track of the number of files changed.
Git version 2.1.0 on Mac OSX:
Example: