码迷,mamicode.com
首页 > 其他好文 > 详细

三分钟教你学Git(十六) - 统计

时间:2015-07-02 17:34:30      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

有时候想统计仓库的情况,比如代码量,贡献者之类的。


1 统计某人的commit数量

git log --author="$(git config --get user.name)" --oneline | wc -l


2 统计某人的代码量

git log --author="$(git config --get user.name)" --pretty=tformat: --numstat | awk ‘{adds += $1; subs += $2; all += $1 + $2} END {printf "added lines: %s removed lines : %s all lines: %s\n",adds,subs,all}‘


3 提交排名top 10

%aN代表只显示commit的author name。也可以使用%ae,使用author email,防止出现重名的情况。然后按照名字或者email排序,之后uniq的时候数count,之后按照第一列的值按照number的方式排序,最后取前10条记录。


 git log --pretty=%aN | sort | uniq -c | sort -k1 -n -r | head -n 10


4 统计有多少个代码贡献者

sort -u 等于 sort | uniq


git log --pretty=%aN | sort -u | wc -l


原文:http://blog.csdn.net/hongchangfirst/article/details/46606707

作者:hongchangfirst

hongchangfirst的主页:http://blog.csdn.net/hongchangfirst



版权声明:本文为博主原创文章,未经博主允许不得转载。

三分钟教你学Git(十六) - 统计

标签:

原文地址:http://blog.csdn.net/hongchangfirst/article/details/46606707

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!