yuanrui / blog

Some notes.
http://yuanrui.github.io
3 stars 0 forks source link

Git统计代码行数 #43

Open yuanrui opened 1 year ago

yuanrui commented 1 year ago

统计变更代码行数

git log --pretty=tformat: --since="2022-07-05" --until="2022-07-21" --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "新增行数: %s, 移除行数: %s, 总行数: %s\n", add, subs, loc }'

统计提交次数

git log --since="2022-07-05" --until="2022-07-21" --no-merges | grep -e 'commit [a-zA-Z0-9]*' | wc -l

查看每人代码行数

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