[英]How to aggregate code changes between commits
我想查看类似汇总的git log --shortstat --oneline
。
代替以下内容,
2fd8b62 quote sending successfully
5 files changed, 26 insertions(+), 40 deletions(-)
5bc977e Hackedup old (redundant) code so that project compiles
14 files changed, 90 insertions(+), 80 deletions(-)
我想要类似的东西
19 files changed, 116 insertions, 120 deletions.
我知道这将包含很多冗余数据(因为文件更改可能很常见,等等),但是我想跟踪一天(例如)或任何时间段内完成的工作。
我想不出一种简单的方法来解析由...生成的输出
git log --shortstat --oneline commit1...commit2
要找到总的变化,我可以做
git diff --shortstat --oneline commit1...commit2
但是我不要 我认为每次提交都是有效的更改,即使在以后的提交中部分撤消了该更改。
该要点给出了可能的解决方案:
git log --shortstat | grep "files changed" | gawk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
在多行中,为了提高可读性:
git log --shortstat | grep "files changed" | \
gawk '{files+=$1; inserted+=$4; deleted+=$6} END \
{print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
我刚刚在git repo上尝试了10天的提交(即使在Windows上也可以使用):
c:\prgs\vonc\git\git>
git log --oneline --shortstat --since="10 days ago" | grep "files changed" | gawk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'
files changed 47 lines inserted: 397 lines deleted: 30
使用相同的技术( 使用gawk
),您可以聚合其他数据,例如每个作者的提交次数:
git log --pretty=format:%an | gawk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'| gsort -r
git log --pretty=format:%an | \
gawk '{ ++c[$0]; } END \
{ for(cc in c) printf "%5d %s\n",c[cc],cc; }'| gsort
同样,在git repo上,在Windows上,它确实可以工作:
c:\prgs\vonc\git\git>
git log --pretty=format:%an --since="10 days ago" | gawk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'| gsort
23 Junio C Hamano
8 Jeff King
3 Johannes Schindelin
请注意,这有点过大,因为它包括合并提交。
更简单的是
c:\prgs\vonc\git\git>
git shortlog -sn --no-merges --since="10 days ago"
8 Jeff King
6 Junio C Hamano
3 Johannes Schindelin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.