每个文件的git日志提交计数 [英] git log commit count for every file

查看:110
本文介绍了每个文件的git日志提交计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从 git log 获取以下内容:
1-回购库中每个文件的提交数量(两个日期之间)
2-编辑每个文件(两个日期之间)的贡献者数量
3-编辑每个文件(两个日期之间)的不同贡献者数量

我试过玩过 git log ,但我没那么成功。我也尝试搜索脚本,但没有运气。任何帮助?

解决方案

(当使用通常的Unix工具时)

在回购中提交给定的文件:

  git log --oneline $ {filename} | wc -l 

给定文件的贡献者数量:

  git log --pretty = format:%ae $ {filename} | sort -u | wc -l 

两个日期之间给定文件的贡献者数量:

  git log --since = $ {date1} --until = $ {date2} --pretty = format:%ae $ {filename} \ 
| sort -u | wc -l

现在,为了对当前仓库中的每个文件进行迭代,以下行:

  find | grep -v'^ \。/ \.git'|而读文件名

echo$ {filename} has $(git log --oneline $ {filename} | wc -l)commitits
done


I'm trying to get the following from git log: 1- number of commits for every file in the repo (between two dates) 2- number of contributors who edited every file (between two dates) 3- number of distinct contributors who edited every file (between two dates)

I've tried playing with git log but I wasn't that successful. I also tried searching for scripts but with no luck. Any help?

解决方案

(when using the usual Unix tools)

Number of commits for given file in the repo:

git log --oneline ${filename} | wc -l

Number of contributors for given file:

git log --pretty=format:%ae ${filename} | sort -u | wc -l

Number of contributors for given file between two dates:

git log --since=${date1} --until=${date2} --pretty=format:%ae ${filename} \
    | sort -u | wc -l

Now, to iterate this for every file in current repo, you'd do something along the lines of:

find | grep -v '^\./\.git' | while read filename
do
    echo "${filename} has $(git log --oneline ${filename} | wc -l) commits"
done

这篇关于每个文件的git日志提交计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆