- 统计代码总行数
git log --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 }'
- 统计某个人在某个时间段内的提交
- author 对应git提交者的名称。
- since 对应开始时间节点
- until 对应结束时间节点
git log --author=sujing --since=2019-01-01 --until=2020-02-01 --format='%aN' | sort -u | while read name; do echo -en "$name\t"; 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: %s\n", add, subs, loc }' -; done
3.统计每个人的代码行数
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