首页 > 技术文章 > 三分钟教你学Git(十六) - 统计

mengfanrong 2016-02-21 09:52 原文

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


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



推荐阅读