简体   繁体   English

如何确定git commit的百分比接触文件或目录?

[英]How can I determine what % of git commits touch a file or directory?

I'm trying to use git log to look through the commit history and figure out, given a period of time, how many commits touched certain sub-folders of the codebase. 我正在尝试使用git log来查看提交历史记录,并找出给定的时间,有多少个提交触及了代码库的某些子文件夹。

Maybe there is a tool out there that reports this sort of statistics. 也许那里有一个工具可以报告这种统计信息。 But I feel like this should be possible as a one-liner or short script of commands. 但是我觉得这应该是单行的或简短的命令脚本。

I'm on Windows, but a unix friendly script would be great. 我在Windows上,但是unix友好的脚本会很棒。

The easy way to get the number of commits that touched a files is to just look at the log for that file. 获取触摸文件的提交次数的简单方法是仅查看该文件的日志。

git log --follow -- path/to/my/file

The --follow will follow renames, and the -- is there in case the file path is ambiguous (and looks like a branch name or something). --follow将跟随重命名,并且--在文件路径不明确(并且看起来像分支名称或类似名称)的情况下位于--

You can count the results with: 您可以使用以下方法计算结果:

git log --format=oneline --follow -- _exec.sh  | wc -l

The total number of commits is given by: 提交总数由下式给出:

git rev-list HEAD | wc -l

These commands will look at the current branch (and its ancestors) only, you can look at stats for all branches by passing --all to both rev-list and log . 这些命令将仅查看当前分支(及其祖先),您可以通过将--all传递给rev-listlog来查看所有分支的统计信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM