![233d32dd1fff88f3c2d67a09145b2c23.png](https://i-blog.csdnimg.cn/blog_migrate/5e43b2783760886e7f03dd2459d3dd26.jpeg)
一、git命令统计
1、统计某人代码提交量
git log --author="mengfanxiao" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %sn", add, subs, loc }' -
2、统计所有人代码提交量(指定统计提交文件类型)
git log --format='%aN' | sort -u | while read name; do echo -en "$namet"; git log --author="$name" --pretty=tformat: --numstat | grep "(.html|.java|.xml|.properties|.css|.js|.txt)$" | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %sn", add, subs, loc }' -; done
3、统计某时间范围内的代码提交量
git log --author=mengfanxiao --since=2019-01-01 --until=2021-02-01 --format='%aN' | sort -u | while read name; do echo -en "$namet"; git log --author="$name" --pretty=tformat: --numstat | grep "(.html|.java|.xml|.properties)$" | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %sn", add, subs, loc }' -; done
结果:added lines: 106243, removed lines: 14088, total lines: 92155
4、查看git提交前5名
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5
![6957bb2dc29d011848ac606a82f60c14.png](https://i-blog.csdnimg.cn/blog_migrate/ff3b2b5c5157d44fe2a10b14172ba285.jpeg)
5、贡献值统计
git log --pretty='%aN' | sort -u | wc -l
6、提交数统计
git log --oneline | wc -l
7、统计或修改的行数
git log --stat|perl -ne 'END { print $c } $c += $1 if /(d+) insertions/'
二、idea statstic 统计
1、安装statstic插件
![b189b2fa1baec9f60ef5c82255fa4b54.png](https://i-blog.csdnimg.cn/blog_migrate/94f181c56da992a88d73b4aaac7fb891.jpeg)
2、安装插件
![d45fe1bc0833ecae91a92285fadfafb6.png](https://i-blog.csdnimg.cn/blog_migrate/a136ff60545eaf7ced70557ee3deedf8.jpeg)
3、已安装好的效果 然后重启下idea
![aaf90afb7a2921b19cb0d9945a0386d1.png](https://i-blog.csdnimg.cn/blog_migrate/2bccfebbfc0967bbf483cce2b2261b05.jpeg)
4、重启了之后 就会出现stastic 选中要查看的代码 点击 refresh on selection
![c93845a09d1c897041758a535d652f7b.png](https://i-blog.csdnimg.cn/blog_migrate/4ae45382d95d8601cef48697e41556e4.jpeg)
5、overview是全部文件 其他的tab页签 如css html java js properties txt xml 可以配置
![af18850363de19b6ae7511c69be4d322.png](https://i-blog.csdnimg.cn/blog_migrate/e9770cab31a4e230407e7c771a73ccb1.jpeg)
6、配置方式
1)点击settings
![955487056f559a0521768e2ebeb10950.png](https://i-blog.csdnimg.cn/blog_migrate/b4c2edd10f06abe242153e4ce119c128.jpeg)
2)配置文件类型
![a1fcbf3187a5f2e85ac98321d0d3f687.png](https://i-blog.csdnimg.cn/blog_migrate/a29925329f72f02b0bcb329c58092d44.jpeg)
三、gitstat (感觉最有意思的方式)
git clone git://github.com/hoxu/gitstats.git
cd gitstats./gitstats 你的项目的位置 生成统计的文件夹位置可能会提示没有安装gnuplot画图程序,那么需要安装再执行://mac osx
brew install gnuplot
//centos linuxyum install gnuplot用mac brew安装的时候 速度可能很慢 处理方式更换国内阿里云上的homebrew镜像:# 替换brew.git:cd "$(brew --repo)"git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git# 替换homebrew-core.git:cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git# 替换homebrew-bottles:echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrcsource ~/.zshrc切换好安装源之后 再使用brew命令就会分块安装好之后 执行命令就会生成html文档访问页面 首先看到项目概括 总文件、代码总行数、总提交次数、多少个作者提交记录
作者提交记录统计
![6f163cccaeeb4f642fc5e97e509bcd57.png](https://i-blog.csdnimg.cn/blog_migrate/8cd9b928b90397c553b146be27848744.jpeg)
![17e10dceceb29913a2c6ad55343533e6.png](https://i-blog.csdnimg.cn/blog_migrate/d78c1a2b95547cc2e6e7f07c88d04b22.jpeg)
![0f125dfbf157f5d9a0e044ba89cfd450.png](https://i-blog.csdnimg.cn/blog_migrate/054727921c91d484c04a7ce4dc727e39.jpeg)
![c8df4c8ed73103baca64a8030e578a43.png](https://i-blog.csdnimg.cn/blog_migrate/635079055159384634ece32f77dca453.jpeg)
四、使用 cloc
1、
brew install cloc
![81a67a211e721a58dceb4fbece17ab72.png](https://i-blog.csdnimg.cn/blog_migrate/36c969562ef4a8a9c24db20a8cca3c29.jpeg)
2、统计当前文件夹代码量
![a9cd4ba18b8dd76b64cece5b5f9310d7.png](https://i-blog.csdnimg.cn/blog_migrate/33a49934c4008f0795d1047b5332b146.jpeg)
3、统计排除当前目录下的某个文件夹的代码量(这里以Pods文件夹为例)
cloc ./ --exclude-dir=Pods
3、统计特定文件的代码量(这里以acpi为例)
cloc -by-file acpi
4、帮助文档
![1676417c95cbe95e2fbc5c0eb8b66434.png](https://i-blog.csdnimg.cn/blog_migrate/c68aa603486d019d343400d84160fef4.jpeg)