天天看点

统计本地Git仓库中不同贡献者的代码行数的一些方法

简单的查看和统计

1.显示所有贡献者及其commit数

git shortlog –numbered –summary
           

2.只看某作者提交的commit:

显示行数的统计:

1.Mac,Linux下可以

2.使用ruby

git ls-files -z | xargs -n1 git blame -w | ruby -n -e ‘$_ =~ /^.*\((.*?)\s[\d]{}/; puts $1.strip’ | sort -f | uniq -c | sort -n
           

3.统计不同编程语言的行数 这一点不是针对git仓库的,所有的项目都可以,这里我们使用的工具是:cloc (count lines of code)

//mac osx
brew install cloc
// linux 可以用yum或者apt安装,当然也可以自己make install
//使用示例:
cd my_project
cloc ./ –exclude-dir=node_modules,public/lib,public/vendor,public/build –exclude-lang=CSS
           

非常详细的统计

要想得到非常详细的统计,例如提交时间表,代码随时间的增长曲线等,可以使用gitstats

git clone git://github.com/hoxu/gitstats.git
cd gitstats
./gitstats 你的项目的位置 生成统计的文件夹位置
           

可能会提示没有安装gnplot画图程序,那么需要安装再执行:

//mac osx
brew install gnplot
//centos linux
yum install gnplot
           

原文链接:统计本地Git仓库中不同贡献者的代码行数的一些方法