如何统计Git存储库中特定作者更改的总行数? [英] How to count total lines changed by a specific author in a Git repository?

查看:446
本文介绍了如何统计Git存储库中特定作者更改的总行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个我可以调用的命令,它将计算Git存储库中特定作者更改的行数?我知道必须有方法来计算Github为其Impact图所做的提交次数。 输出下面的命令应该相当容易发送给脚本来合计总和:

  git log --author =< AUTHORNAME>中--oneline --shortstat 

这给出了当前HEAD上所有提交的统计信息。如果您想在其他分支中添加统计信息,您必须将它们作为参数提供给 git log



为了传递给脚本,甚至可以使用空的日志格式删除oneline格式,并且如JakubNarębski所述, --numstat 是另一种选择。它生成每个文件而不是每行统计信息,但更易于解析。

  git log --author =< ; AUTHORNAME>中--pretty = tformat:--numstat 


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.

解决方案

The output of the following command should be reasonably easy to send to script to add up the totals:

git log --author="<authorname>" --oneline --shortstat

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.

git log --author="<authorname>" --pretty=tformat: --numstat

这篇关于如何统计Git存储库中特定作者更改的总行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆