git - 获取有关特定目录中行贡献的 Git 统计信息

标签 git

我希望看到统计数据告诉我哪些作者在给定目录中贡献了多少行

git-extras和其他一些类似的工具存在,但我无法确定是否可以使用它们(或其他任何工具)将我的统计信息限制在给定目录中。

有什么想法吗?

最佳答案

你可以使用一个简短的脚本:

#!/bin/bash

git shortlog -s -- $1 | cut -c8- | while read i
do
    git log --author="$i" --pretty=tformat: --numstat -- $1 \
    | awk -v name="$i" '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "%s: added lines: %s removed lines: %s total lines: %s\n", name, add, subs, loc }'
done

将其命名为 loc.sh 然后运行:loc.sh [目录/文件]

输出应该是这样的:

Name1: added lines: 10757 removed lines: 49 total lines: 10708
Nmae2: added lines: 1193 removed lines: 94255 total lines: -93062

查看更多herehere

关于git - 获取有关特定目录中行贡献的 Git 统计信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36847268/

相关文章:

git - 在 SmartGit 中从主分支更改为开发分支

git - 是否可以为不同的文件夹设置不同的 .gitconfig 文件

git - 为什么我得到 : `warning: not deleting branch ' accounting' that is not yet merged to`?

git - 如何在 Visual Studio 2010 Beta 2 上安装 GitExtensions?

python - 在python中找不到git可执行文件

windows - PowerShell-git checkout -B没有重置或替代方法?

git - 我应该在开发完成之前 merge dev 和 master 分支吗?

git - 如何正确使用带有 Git 钩子(Hook)的 CI 脚本来压缩源代码

android - 将带有版本控制系统的eclipse android项目导入Android Studio

git - 如何同步两个git仓库