最近,我发现我正在处理的项目比我预期的更多错误,我想知道在我们的sprint中哪些文件发生了最大的变化。
我可以做这样的事情,但它只显示哪些文件被更改,但没有显示他们被更改了多少次
git diff --name-only SHA1 SHA2
请让我按正确的方向编写一个脚本,以显示两次提交之间大多数时间内更改的文件。
提前致谢。
答案 0 :(得分:1)
git log --name-only --format=%n SHA1..SHA2 | Group-Object | Format-Table Count,Name
使用--format=%n
为每个提交获取一个空行,将它们全部折叠为一个已排序和计数的条目。然后在Group-Object
。
来自here的| sort | uniq -c
的Powershell翻译。
答案 1 :(得分:0)
从git-diff documentation开始,您需要--stat
或--numstat
,具体取决于您希望输出的显示效果:
git diff --stat hash1 hash2
.file1.un~ | Bin 0 -> 948 bytes
.file2.un~ | Bin 0 -> 523 bytes
file1 | 25 +++++++++++++++++++++++++
file2 | 8 ++++++++
4 files changed, 33 insertions(+)
或者
git diff --numstat hash1 hash2
- - .file1.un~
- - .file2.un~
25 0 file1
8 0 file2
答案 2 :(得分:0)
最近10次提交的示例。随意根据您的需要进行更改。如果您遇到超过2位数的事件,请相应更改sprintf
表达式"%02d"
。
git log --name-only --pretty="%n" HEAD~10..HEAD |
egrep '.' |
sort |
uniq -c |
perl -pe 's/([0-9]+)/sprintf("%02d",$1)/e' |
sort -r |
less