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

时间:2015-07-15 15:24:28

标签: git

这更像是一种好奇而不是特定的需求,但随着时间的推移,我的团队已经发生了很大变化。我们不得不吹走已经存在一段时间的一些功能,这让我感到疑惑。有没有我可以搜索回购,看看是否还有用户A留下的代码。

我知道我可以对特定文件做一个git责备,看看用户A中是否有任何行,但有没有办法可以在整个仓库中做到这一点?

编辑按"代码左"我的意思是用户A在2010年1月1日写了一行代码,而且这行代码今天保持不变。

基本上,就像WebSocket一样,它显示该行旁边的用户名,但是在整个仓库而不是单个文件上。

2 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:1)

我们使用gitinspector。这可以显示用户拥有多少行"甚至通过-r选项显示给定用户最拥有的文件。