天天看點

統計本地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倉庫中不同貢獻者的代碼行數的一些方法