Skip to content

Instantly share code, notes, and snippets.

@yuanliwei
Last active April 12, 2019 02:59
Show Gist options
  • Save yuanliwei/1570bacc8c8335b542e19ff2231e5706 to your computer and use it in GitHub Desktop.
Save yuanliwei/1570bacc8c8335b542e19ff2231e5706 to your computer and use it in GitHub Desktop.
Git 统计命令.md

统计每个人的代码行数

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

用户提交次数排名

  • git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r
  • git shortlog | grep '^[^ ]'

邮箱提交次数排名

git log --pretty=format:%ae | gawk -- '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' | sort -u -n -r

贡献者统计

git log --pretty='%aN' | sort -u | wc -l

提交数统计

git log --oneline | wc -l

添加或修改的代码行数统计

git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/;'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment