git log --pretty=%aN | sort -u
sort -u 等于 sort | uniq
git log --pretty=%aN | sort -u | 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
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --since="2019-3-1" --until="2019-12-10" --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
# format-1
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --since="2019-3-1" --until="2019-12-10" --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { if(loc>0)printf "added lines: %s\t, removed lines: %s\t, total lines: %s\t", add, subs, loc }' -; echo "\t"; done
# format-2 展示0
git log --format='%aN' | sort -u | while read name; do echo -en "$name===>\t"; git log --author="$name" --pretty=tformat: --since="2019-3-1" --until="2019-12-10" --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { if(loc>0){printf "addedLines: %s\t removedLines: %s\t totalLines: %s\n", add, subs, loc }else{printf "addedLines: 0\t removedLines: 0\t totalLines: 0\n"}}' -; done
# format-3 过滤0
git log --format='%aN' | sort -u | while read name; do echo -en "$name===>\t"; git log --author="$name" --pretty=tformat: --since="2019-3-1" --until="2019-12-10" --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { if(loc>0){printf "addedLines: %s\t removedLines: %s\t totalLines: %s\n", add, subs, loc }else{printf "addedLines: 0\t removedLines: 0\t totalLines: 0\n"}}' -; done |grep -v 'totalLines: 0'
# format-4 过滤0+排序+top10
git log --format='%aN' | sort -u | while read name; do echo -en "$name===>\t"; git log --author="$name" --pretty=tformat: --since="2019-3-1" --until="2019-12-10" --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { if(loc>0){printf "addedLines: %s\t removedLines: %s\t totalLines: %s\n", add, subs, loc }else{printf "addedLines: 0\t removedLines: 0\t totalLines: 0\n"}}' -; done |grep -v 'totalLines: 0' | sort -k7 -n -r | head -n 10
git log --author="$(git config --get user.name)" --pretty=tformat: --numstat | awk '{adds += $1; subs += $2; all += $1 + $2} END {printf "added lines: %s removed lines : %s all lines: %s\n",adds,subs,all}'
git log --author="$(git config --get user.name)" --pretty=tformat: --since="2019-5-1" --until="2019-12-10" --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'
%aN代表只显示commit的author name。也可以使用%ae,使用author email,防止出现重名的情况。然后按照名字或者email排序,之后uniq的时候数count,之后按照第一列的值按照number的方式排序,最后取前10条记录。
git log --pretty=%aN | sort | uniq -c | sort -k1 -n -r | head -n 10
git log --author="$(git config --get user.name)" --oneline | wc -l
git log --author=$(git config --get user.name) --since="2019-08-01" --no-merges | grep -e 'commit [a-zA-Z0-9]*' | wc -l