- 統(tǒng)計代碼總行數
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 }'
- 統(tǒng)計某個人在某個時間段內的提交
- author 對應git提交者的名稱式塌。
- since 對應開始時間節(jié)點
- until 對應結束時間節(jié)點
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.統(tǒng)計每個人的代碼行數
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