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

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

问题描述

是否有我可以调用的命令来计算 Git 存储库中特定作者更改的行数?我知道必须有办法计算提交的数量,因为 Github 为他们的影响图做了这个.

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

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

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.

为了传递给脚本,甚至可以使用空日志格式删除oneline"格式,正如 Jakub Narębski 所评论的那样,--numstat 是另一种选择.它生成每个文件而不是每行的统计信息,但更容易解析.

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天全站免登陆