git统计每个人的代码行数_Git代码行数统计命令

  • Post author:
  • Post category:其他


目录下(包含.git的目录)

401d2f410d0a1ccfabacee590a98769c.png

1.统计sujing在某个时间段内的git新增/删除代码行数

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

120552f407f2e50046f6633fb45f6b64.png

2.统计该项目所有的代码数

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 }'

1f9781531a9f13b0c55452b6712d8536.png