【问题标题】:How can I sum up the lines added/removed by a user in a git repo?如何总结用户在 git repo 中添加/删除的行?
【发布时间】:2011-02-17 07:07:36
【问题描述】:

我正在尝试查找用户在 git 存储库中添加的总行数和删除的总行数。我查看了How to count total lines changed by a specific author in a Git repository?,它有命令git log --author="<authorname>" --pretty=tformat: --numstat,但答案没有给出一个脚本(无论多么简单)来改变总行数。总结添加/删除的行的最简单方法是什么?

【问题讨论】:

    标签: git scripting


    【解决方案1】:
    $ git log --author="<authorname>" --pretty=tformat: --numstat | perl -ane'
    > $i += $F[0]; $d += $F[1]; END{ print "added: $i removed: $d\n"}'
    

    【讨论】:

      【解决方案2】:

      也可以使用 awk:

      git log --author="<authorname>" --pretty=tformat: --numstat | awk -F" " '{ added += $1; removed += $2 } END { print "added: ",  added, "removed:", removed }'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-01-31
        • 1970-01-01
        • 2013-05-25
        • 2017-10-02
        • 1970-01-01
        • 2014-06-06
        • 2012-12-20
        • 2012-05-22
        相关资源
        最近更新 更多