// 查詢所有提交者
git log --since ==2017-09-01 --until=2017-09-28
--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 --since=2017-05-21 --until=2017-06-20 --author="author-name" --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
默認不用任何參數(shù)的話,git log 會按提交時間列出所有的更新,最近的更新排在最上面。
--pretty 選項,可以指定使用完全不同于默認格式的方式展示提交歷史。
format,可以定制要顯示的記錄格式,這樣的輸出便于后期編程提取分析,像這樣:
$ git log --pretty=format:"%h - %an, %ar : %s"
ca82a6d - Scott Chacon, 11 months ago : changed the version number
085bb3b - Scott Chacon, 11 months ago : removed unnecessary test code
a11bef0 - Scott Chacon, 11 months ago : first commit
下表列出了常用的格式占位符寫法及其代表的意義。

常用的格式占位符
git log 命令支持的常用選項及其釋義。

選項及釋義
git log常用搜索條件

常用搜索條件