统计提交的代码行数

1,755 阅读1分钟

统计行数命令如下

git log --numstat --pretty="%H" ${startCommit}..${endCommit} | awk 'NF==3 {plus+=$1; minus+=$2; total += $1 + $2;} END {printf("%d,%d,%d", plus, minus, total)}'

统计从startCommit到endCommit提交的代码行数,分别是起始commitID、终止commitID

步骤一: 运行命令git log查看提交ID,如下图

步骤二:

5cdf5722f66c0f673b69a762fb56c21f67e994c3替换${startCommit}

c01f635b878e52c9366ddadf6c40d24931eef07c替换${endCommit}

输出如下:

红框内结果依次为:新增行数,删减行数,总行数