git log --author="username" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -
結果示例:(記得修改 username)linux
added lines: 120745, removed lines: 71738, total lines: 49007
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
結果示例git
Max-laptop added lines: 1192, removed lines: 748, total lines: 444 chengshuai added lines: 120745, removed lines: 71738, total lines: 49007 cisen added lines: 3248, removed lines: 1719, total lines: 1529 max-h added lines: 1002, removed lines: 473, total lines: 529 max-l added lines: 2440, removed lines: 617, total lines: 1823 mw added lines: 148721, removed lines: 6709, total lines: 142012 spider added lines: 2799, removed lines: 1053, total lines: 1746 thy added lines: 34616, removed lines: 13368, total lines: 21248 wmao added lines: 12, removed lines: 8, total lines: 4 xrl added lines: 10292, removed lines: 6024, total lines: 4268 yunfei.huang added lines: 427, removed lines: 10, total lines: 417 ³ö added lines: 5, removed lines: 3, total lines: 2
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5
git log --pretty='%aN' | sort -u | wc -l
git log --oneline | wc -l
git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/'
GitStats項目,用Python開發的一個工具,經過封裝Git命令來實現統計出來代碼狀況而且生成可瀏覽的網頁。官方文檔能夠參考這裏。github
git clone git://github.com/hoxu/gitstats.git cd gitstats ./gitstats 你的項目的位置 生成統計的文件夾位置
可能會提示沒有安裝gnuplot畫圖程序,那麼須要安裝再執行:npm
//mac osx brew install gnuplot //centos linux yum install gnuplot
生成的統計文件爲HTML:
segmentfault
npm install -g cloc