Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何在提交之间聚合代码更改_Git_Shell - Fatal编程技术网

Git 如何在提交之间聚合代码更改

Git 如何在提交之间聚合代码更改,git,shell,Git,Shell,我希望看到聚合的git日志--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(-) 我想要像

我希望看到聚合的
git日志--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}'

在过去10天的提交过程中,我只是在上试用了它(它甚至可以在Windows上使用):


使用相同的技术()可以聚合其他数据,例如每个作者的提交数:

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

那很容易。。如果您手头有任何脚本语言;)如果有,可以接受哪些语言?我是说,你只想总结一下日志——shortstat,对吗?是的。因此,我可以在bashshell中输入的任何命令都是可以接受的。实际上,我对shell脚本没有太多的知识
c:\prgs\vonc\git\git>
git shortlog -sn --no-merges --since="10 days ago"
     8  Jeff King
     6  Junio C Hamano
     3  Johannes Schindelin