统计某个时间段内的git新增/删除代码行数
参数说明:
–author 作者 提交者
–after 开始时间
–before 结束时间
–pretty 格式
1.查看总提交行数、移除行数、项目总行数
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 }'
2.查看个人提交的代码行数统计
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 }' -
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
4.查询所有用户的提交总次数
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r
5. 查询所有人截止目前的提交行数、删除行数、总行数信息
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
6.查询所有用户的提交总次数
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r
根据时间查询次数
git log --after="2022-01-01 00:00:00" --before="2022-09-28 00:00:00" --pretty='%aN' | sort | uniq -c | sort -k1 -n -r
7.gitee统计,各用户提交行数
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