gpt4 book ai didi

git - 查看是否有人在 git 存储库中留下任何代码

转载 作者:太空狗 更新时间:2023-10-29 13:24:12 25 4
gpt4 key购买 nike

这更多的是出于好奇而非特定需求,但随着时间的推移,我的团队发生了相当大的变化。我们不得不放弃一些已经存在了一段时间的功能,这让我感到疑惑。有没有什么方法可以让我搜索 repo 协议(protocol),看看是否有用户 A 留下的任何代码。

我知道我可以对特定文件执行 git blame 并查看用户 A 中是否有任何行,但是有什么方法可以对整个存储库执行此操作吗?

编辑“留下代码”是指用户 A 在 2010 年 1 月 1 日写了一行代码,并且该行代码今天保持不变。

本质上,就像 git blame 一样,它在行旁边显示用户名,但在整个存储库而不是单个文件上。

最佳答案

这将打印所有作者的列表以及相应数量的“拥有”行(不包括空行):

git ls-tree -r HEAD|cut -f 2|grep -E '\.(php|js|cc|h|cpp|hpp|c|txt|m)$' | xargs -n1 git blame --line-porcelain|grep "author "|sort|uniq -c|sort -nr

它目前匹配 php、js、cc、h、cpp、hpp、c、m 和 .txt 文件扩展名。

github 存储库的示例输出 UIView-Autolayout :

 747 author liamnichols
458 author James Frost
356 author richard.turton@mubaloo.com
200 author Rich Turton
124 author Richard Turton
49 author Bart Vandendriessche
25 author Tom Guy
15 author David Keegan
14 author Rich Hodgkins
10 author Eric Horacek
10 author Bob Spryn
5 author Liam Nichols
2 author Nirvana Platform
1 author Gert Vanbeckevoort

关于git - 查看是否有人在 git 存储库中留下任何代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31434580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com