How to get total additions and deletions on a given branch for an given author in git

后端 未结 2 976
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 11:55

Is there a way in git to count the total deletions and additions for a given user on a given branch? Something like that is on github, in the graph section there is a chart

2条回答
  •  悲哀的现实
    2020-12-23 12:25

    I don't think Git has any built-in command that does this. But with the help of some other standard utilities, it can be done. Here is an example that filters Git's log output through awk to get the summary of total insertions and deletions:

    git log --author=$USER --shortstat $BRANCH | \
    awk '/^ [0-9]/ { f += $1; i += $4; d += $6 } \
    END { printf("%d files changed, %d insertions(+), %d deletions(-)", f, i, d) }'
    

提交回复
热议问题