如何计算每个文件在git中被修改了多少次? [英] How to count how many times each file was modified in git?

查看:164
本文介绍了如何计算每个文件在git中被修改了多少次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个真正的项目,我们已经计划将其重构几个月,但没有人有时间. 我想查看修改最多的文件,因为这些文件中包含的功能/代码将具有重构和提高工作效率的优先级.

I am working on a real mess of a project and we've been planning to refactor it for months but nobody has the time. I want to see which files are most modified because the features/codes contained in those files will have the priority on refactoring and increasing my productivity.

是否有可能以表格格式或某种形式以git形式获取自首次提交或特定星期以来每个文件被修改的次数?如果可以,怎么办?

Is it possible to get number of times each file was modified since first commit or a specific week, in a table format or something, in git? If so, how?

很抱歉,我没有提供我尝试过的内容",因为坦率地说,我很少从命令行使用git,我真的很能力不足,而GUI只是不够.

I apologize that I do not provide a "what have I tried" because frankly I rarely use git from command line and I'm really poor at it and the GUI ones are just not enough.

推荐答案

计算每个项目的提交次数 您的文件,您可以执行以下操作

To count the number of commits for each of your files, you could do something like this

#!/bin/bash
for file in *.php;
do
echo $file
git log --oneline -- $file | wc -l
done

"git log"是这里的关键git命令.

"git log" is the key git command here.

这里有一些git命令和选项可供查看

Here are some git commands and options to look at

git log 

git log --oneline 

获取特定文件的更改日志

To get a log of changes for a specific file

git log -- filename

获取特定文件的更改日志 在特定日期内您可以

To get a log of changes for a specific file during a specific date you can do

git log --after="2017-05-09T16:36:00-07:00" --before="2017-05-10T08:00:00-07:00" -- myfile

您可能想尝试

git log --pretty=format

您可以查找所有不同的格式

you can look up all the different formats

您可以在github上获得一个私有存储库 并将其全部推上去;那将是一个 很好的图形方式来查看所有更改 更改的任何文件.

You could get a private repository on github and push it all up there; that would be a nice graphical way to see all the changes for any of your changed files.

这篇关于如何计算每个文件在git中被修改了多少次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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